Created
October 10, 2010 09:48
-
-
Save toby55kij/619113 to your computer and use it in GitHub Desktop.
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
// g100pon #70 存在しないメソッド/プロパティアクセスをフック | |
class Some { | |
def doMethod() { | |
println "Method!" | |
} | |
String name | |
def methodMissing(String name, args) { | |
println "method $name ( $args ) is missing!" | |
} | |
def propertyMissing(String name) { | |
println "property $name is missing!" | |
} | |
def propertyMissing(String name, value) { | |
println "property $name = $value is missing!" | |
} | |
} | |
def foo = new Some() | |
foo.doMethod() | |
foo.doOtherMethod(1, 2, 'three') //存在しないメソッド | |
foo.name = 'foo' | |
println foo.name | |
foo.age = 20 //存在しないプロパティへの書き込み | |
println foo.age //存在しないプロパティへのアクセス |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment