public
Last active

Spell: Blank Slate

  • Download Gist
blank_slate.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# ===================
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.