Groovy MetaClass - Add category methods to appropriate metaClasses
Posted
by noah
on Stack Overflow
See other posts from Stack Overflow
or by noah
Published on 2010-03-05T14:35:25Z
Indexed on
2010/05/31
23:33 UTC
Read the original article
Hit count: 402
I have several categories that I use in my Grails plugin. e.g.,
class Foo {
static foo(ClassA a,Object someArg) { ... }
static bar(ClassB b,Object... someArgs) { ... }
}
I'm looking for the best way to add these methods to the meta-classes so that I don't have to use the category classes and can just invoke them as instance methods. e.g.,
aInstance.foo(someArg)
bInstance.bar(someArgs)
Is there a Groovy/Grails class or method that will help me do this or am I stuck iterating through the methods and adding them all myself?
© Stack Overflow or respective owner