Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A
- def extend_me(x)
- x + 1
- end
- end
- # We need to change the way our method works, but retain the original behavior
- # too.
- class A
- old_method = public_instance_method(:extend_me)
- define_method(:extend_me) do |x|
- puts "Inside the new version"
- x *= 3
- old_method.bind(self).call(x)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement