Skip to content

Instantly share code, notes, and snippets.

Created November 7, 2009 18:47
Show Gist options
  • Save anonymous/228837 to your computer and use it in GitHub Desktop.
Save anonymous/228837 to your computer and use it in GitHub Desktop.
String.metaClass.methodMissing { String name, args ->
String camel = ''
name.split('_').eachWithIndex { part, i ->
if (i == 0) camel += part
else camel += (part[0].toUpperCase() + part[1..-1])
}
def method = delegate.metaClass.methods.find { it.name == camel }
if (method) {
return method.invoke(delegate, args)
}
}
println "Who got their Ruby all over my Groovy?".to_upper_case()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment