Skip to content

Instantly share code, notes, and snippets.

@nusco
Created August 18, 2010 13:47
Show Gist options
  • Save nusco/534776 to your computer and use it in GitHub Desktop.
Save nusco/534776 to your computer and use it in GitHub Desktop.
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
@hackervera
Copy link

    .---.                                 ______
   ;     \      _        _        _      |__ __ |
  :    .'      / \      / \      / \     |Þ )Þ )|
  :   :        | |      | |      | |     |      |
  :    '.      \_/      \_/      \_/     |      |
   :     /                               |      |
    '---'                                |/\/\/\|

@nusco
Copy link
Author

nusco commented Sep 15, 2011

:)

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