Ok, found the answer. The delegate is the object the method is called on:
def stringMetaClass = new ExpandoMetaClass(String.class, true)
stringMetaClass.aMethod << { delegate.toUpperCase() }
stringMetaClass.initialize()
assert TEST == "test".aMethod()
Steven
On 2/2/07, Steven Devijver <
steven.devijver@...> wrote:
> Consider this Expando method:
>
> def stringMetaClass = new ExpandoMetaClass(String.class, true)
>
> stringMetaClass.aMethod << { it.toUpperCase() }
>
> stringMetaClass.initialize()
>
> However, when I call the method "it" is null:
>
> "test".aMethod()
>
> How to get hold in a closure of the object where an Expando method is called on?
>
> Thanks
>
> Steven
>
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email