Skip to content

Instantly share code, notes, and snippets.

@scheakur
Created February 2, 2013 00:35
Show Gist options
  • Save scheakur/4695235 to your computer and use it in GitHub Desktop.
Save scheakur/4695235 to your computer and use it in GitHub Desktop.
class Example {
def hoge
def fuga
def piyo
def foo() { "foo" }
def bar() { "$hoge$fuga$piyo" }
}
Example.metaClass.baz = { -> "baz" }
def obj = new Example(hoge: 'a', fuga: 'b', piyo: 'c')
def props = obj.properties
def methods1 = obj.metaClass.methods.name.sort().unique()
def methods2 = obj.class.methods.name.sort().unique()
println """
properties:
${props}
metaClass methods:
${methods1}
class methods:
${methods2}
"""
properties:
[class:class Example, piyo:c, hoge:a, fuga:b]
metaClass methods:
[__$swapInit, bar, baz, equals, foo, getClass, getFuga, getHoge, getMetaClass, getPiyo, getProperty, hashCode, invokeMethod, notify, notifyAll, setFuga, setHoge, setMetaClass, setPiyo, setProperty, toString, wait]
class methods:
[__$swapInit, bar, equals, foo, getClass, getFuga, getHoge, getMetaClass, getPiyo, getProperty, hashCode, invokeMethod, notify, notifyAll, setFuga, setHoge, setMetaClass, setPiyo, setProperty, super$1$clone, super$1$equals, super$1$finalize, super$1$getClass, super$1$hashCode, super$1$notify, super$1$notifyAll, super$1$toString, super$1$wait, this$dist$get$1, this$dist$invoke$1, this$dist$set$1, toString, wait]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment