Created
June 17, 2011 08:05
-
-
Save erdi/1031051 to your computer and use it in GitHub Desktop.
MetaClassMixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grails.test.GrailsUnitTestCase | |
@Category(GrailsUnitTestCase) | |
class MetaClassMixin { | |
Delegate metaClassFor(Class clazz) { | |
registerMetaClass(clazz) | |
new Delegate(target: clazz.metaClass) | |
} | |
Delegate staticMetaClassFor(Class clazz) { | |
registerMetaClass(clazz) | |
new Delegate(target: clazz.metaClass.'static') | |
} | |
private static class Delegate { | |
Object target | |
@Override | |
void setProperty(String property, Object newValue) { | |
target.setProperty(property, newValue) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment