Last active
September 5, 2015 18:54
-
-
Save nusco/534987 to your computer and use it in GitHub Desktop.
Spell: Blank Slate
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
# =================== | |
# Spell: Blank Slate | |
# =================== | |
# Remove methods from an object to turn them into Ghost Methods (http://gist.github.com/534776). | |
class C | |
def method_missing(name, *args) | |
"a Ghost Method" | |
end | |
end | |
obj = C.new | |
obj.to_s # => "#<C:0x007fbb2a10d2f8>" | |
class D < BasicObject | |
def method_missing(name, *args) | |
"a Ghost Method" | |
end | |
end | |
blank_slate = D.new | |
blank_slate.to_s # => "a Ghost Method" | |
# For more information: http://www.pragprog.com/titles/ppmetr/metaprogramming-ruby |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment