Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Spell: Ghost Method
# ===================
# Spell: Ghost Method
# ===================
# Respond to a message that doesn’t have an associated method.
class C
def method_missing(name, *args)
name.to_s.reverse
end
end
obj = C.new
obj.my_ghost_method # => "dohtem_tsohg_ym"
# For more information: http://www.pragprog.com/titles/ppmetr/metaprogramming-ruby
    .---.                                 ______
   ;     \      _        _        _      |__ __ |
  :    .'      / \      / \      / \     |Þ )Þ )|
  :   :        | |      | |      | |     |      |
  :    '.      \_/      \_/      \_/     |      |
   :     /                               |      |
    '---'                                |/\/\/\|
Owner

nusco commented Sep 15, 2011

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment