« Return to Thread: Adding method as GString expression to per-instance metaclass

Re: Adding method as GString expression to per-instance metaclass

by Robert Fischer :: Rate this Message:

Reply to Author | View in Thread

Does expando.getTest() work?

~~ Robert.


Setya wrote:

> Hi all,
>
> I tried to add dynamic method to per-instance metaclass, the method itself
> is in the form of GString expression as follows:
>
> def emc = new ExpandoMetaClass(Expando);
> def methodName = 'getTest';
> emc."$methodName" = {-> println 'Hello World';};
> emc.initialize();
>
> def expando = new Expando();
> expando.metaClass = emc;
>
> Than I call the method :
>
> expando.test;
>
> No error was thrown but the closure within 'getTest' is never called
>
> Any ideas ?
>
> Regards,
>
> Setya

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Adding method as GString expression to per-instance metaclass