Skip to content

Instantly share code, notes, and snippets.

@jbodah
Created November 19, 2014 03:50
Show Gist options
  • Save jbodah/7b456fc975382ddb3ffe to your computer and use it in GitHub Desktop.
Save jbodah/7b456fc975382ddb3ffe to your computer and use it in GitHub Desktop.
reattach method
irb(main):001:0> receiver = Object.new
=> #<Object:0x007fc4a1939320>
irb(main):002:0> original = receiver.method(:to_s)
=> #<Method: Object(Kernel)#to_s>
irb(main):003:0> original == receiver.method(:to_s)
=> true
irb(main):004:0> receiver.define_singleton_method(:to_s, original)
=> :to_s
irb(main):005:0> original == receiver.method(:to_s)
=> false
irb(main):006:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment