MethodMissing Invoke method issue

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

MethodMissing Invoke method issue

Hi All,

Can u tell me how to use invokeMethod and methodMissing together on same object.As per my observance invokeMethod invokes for both existing and none existing methods..How to use both on same object so that available methods to go to invoke method and others to route to methodmissing?

class Person {
void work() {
println 'work'
def p = new Person()
p.metaClass.invokeMethod={String name,args -> println 'invokemethod'}
p.metaClass.methodmissing={String name,args-> println 'method mising'} //calls invokemethod
p.test() //calls invokemethod

I want work() to goto invoke mehtod and test() to goto methodmissing.How to do this?