Skip to content

Instantly share code, notes, and snippets.

@nusco
Created August 18, 2010 13:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • 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
@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