Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created January 20, 2012 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leejarvis/ebc00248f7c5b998b3bf to your computer and use it in GitHub Desktop.
Save leejarvis/ebc00248f7c5b998b3bf to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
class Foo
def hello
puts "Original hello!"
end
end
foo = Foo.new
foo.class.send(:alias_method, :orig_hello, :hello)
foo.class.send(:define_method, :hello) { puts 'New Hello!'; orig_hello }
foo.hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment