Try this:

ExtendMe = new Class ({
  'doIt': function() {'console.log('i did it')}
})

IExtend = new Class({
  'initialize: function(*dynamicClass*){
    $extend(this.constructor, *dynamicClass*);
    // this.constructor here is exactly the IExtend Class

  }
})

iExtend = new IExtend(*ExtendMe*);
iExtend.doIt(); // but this doesnt work...

--
Fábio Miranda Costa
Solucione Sistemas
Engenheiro de interfaces


On Wed, Dec 16, 2009 at 10:53 AM, Roman Land <[email protected]> wrote:

> Not exactly, I did RTFM :)
>
> I want to extend or implement a class dynamically, like so:
>
>
> ExtendMe = new Class ({
>   'doIt': function() {'console.log('i did it')}
> })
>
> IExtend = new Class({
>   'initialize: function(*dynamicClass*){
>     $extend(this, *dynamicClass*);
>   }
> })
>
> iExtend = new IExtend(*ExtendMe*);
>
> iExtend.doIt(); // but this doesnt work...
>
>
>
> 2009/12/16 Fábio M. Costa <[email protected]>
>
> I think you need Extends.
>>
>> http://mooshell.net/sHakv/1/
>>
>> --
>> Fábio Miranda Costa
>> Solucione Sistemas
>> Engenheiro de interfaces
>>
>>
>>
>> On Wed, Dec 16, 2009 at 9:09 AM, Slik Jay <[email protected]> wrote:
>>
>>> Something*
>>>
>>> On Wed, Dec 16, 2009 at 1:09 PM, Slik Jay <[email protected]> wrote:
>>> > http://mooshell.net/sHakv/
>>> > Thomesing like this ?
>>> >
>>> > On Wed, Dec 16, 2009 at 12:52 PM, Roman Land <[email protected]>
>>> wrote:
>>> >> Hi,
>>> >>
>>> >> Is there any way to extend / implement a class while initializing it?
>>> >> example:
>>> >>
>>> >> ExtendMe = new Class ({
>>> >>   'doIt': function() {'console.log('i did it')}
>>> >> })
>>> >>
>>> >> IExtend = new Class({
>>> >>   'initialize: function(){
>>> >>     $extend(this, extendMe);
>>> >>   }
>>> >> })
>>> >>
>>> >> iExtend = new IExtend();
>>> >> iExtend.doIt(); // but this doesnt work...
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> ---
>>> >> "Make everything as simple as possible, but not simpler."
>>> >>
>>> >> - Albert Einstein
>>> >>
>>> >>
>>> >
>>>
>>
>>
>
>
> --
> ---
> "Make everything as simple as possible, but not simpler."
>
> - Albert Einstein
>
>

Reply via email to