atom feed11 messages in org.codehaus.grails.dev[grails-dev] Overwriting a metaClass ...
FromSent OnAttachments
gmailApr 23, 2010 11:25 am 
Scott BurchApr 23, 2010 11:41 am 
Scott BurchApr 23, 2010 11:54 am 
gmailApr 23, 2010 11:55 am 
Scott BurchApr 23, 2010 12:07 pm 
gmailApr 23, 2010 12:46 pm 
Jeff BrownApr 23, 2010 1:03 pm 
gmailApr 23, 2010 1:42 pm 
K. Michael WilleApr 23, 2010 2:03 pm 
Jeff BrownApr 23, 2010 2:08 pm 
gmailApr 23, 2010 2:37 pm 
Subject:[grails-dev] Overwriting a metaClass method
From:gmail (mike@flowz.com)
Date:Apr 23, 2010 11:25:30 am
List:org.codehaus.grails.dev

Apologies for what might be a newbie question...

I'm trying to override a method/closure that a plugin added to the metaClass of
a particular set of classes. (controllers, services, etc.) If I simply assign
a new closure to the metaClass, it appears to append that closure and both the
first and the second get called. I'd like to "clear" the closure so that only
mine gets called, but I can't figure out to do this.

E.g.,

It appears that doing something like:

application.controllerClasses*.metaClass*.sendMail = { // closure to replace
mail plugin's sendMail }

Simply adds a second closure that is called before the mail plugin's closure.
If I try to "clear out" the closure with something like:

application.controllerClasses*.metaClass*.sendMail = null // or application.controllerClasses*.metaClass*.sendMail = { // empty }

There still ends up being two closures called. Any pointers?

Thanks!

-Mike