Hi,

Ryan, your Object.inherit() implementation looks great, but I couldn't
use it for my needs.
I want to internally extend my own object, like adding a plugin, and
refer also to the current implementation of the object.
You're not able to use Object.inherit(this,this);

Example:
***********
var A = Class.create();
Object.extend(A,{
   addPlugin: function(pluginObj) {
      var $parent = Object.clone(this);
      Object.extend(this,pluginObj);
   },
   show: function() {
      alert("I am A");
   }
});
A.addPlugin({
   show: function() {
      $parent.show();
      alert("I am EXTENDED A");
   }
});
A.show();
***********

Actually, even my example does not work (I checked it before a bit
differently and I thought it works).
How can this addPlugin can be implemented?

-thanks, Eli



On Mar 30, 12:50 am, "Ryan Gahl" <[EMAIL PROTECTED]> wrote:
> You may find my blog entry from last week to be interesting 
> here:http://www.someelement.com/2007/03/multiple-inheritance-with-prototyp...
>
> As I state in the entry, I borrow from Kevin Lindsey's inheritance model,
> but have made it work quite nicely with prototype, and honestly think it
> would fit nicely into the core (keep Object.extend as is but add
> Object.inherit)
>
> On 3/29/07, Mislav Marohnić <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > On 3/30/07, Lorderon <[EMAIL PROTECTED]> wrote:
>
> > > Many times there's a need to call the parent method from the extended
> > > class object.
> > > This can be done easily by adding the $parent to be used inside
> > > Object.extend() method.
>
> > You're touching sensitive ground here. There are many OOP implementations
> > in JavaScript: 2 or 3 are for Prototype (you can find them in Trac), there
> > are several on various sites and blogs, but the most notable (IMO) is Dean
> > Edwards' Base.
>
> > We're aiming to bring support for something like Base in Prototype 2.0. I
> > believe that we will begin experimenting starting from version 1.6, but I
> > still need to check with Sam for find out if his intentions have maybe
> > changed in the past few months.
>
> --
> Ryan Gahl
> Application Development Consultant
> Athena Group, Inc.
> Inquire: 1-920-955-1457
> Blog:http://www.someElement.com- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to