Skip to content

Instantly share code, notes, and snippets.

@MatthewRDodds
Last active August 29, 2015 14:14
Show Gist options
  • Save MatthewRDodds/98c73939c36d98ff2bcd to your computer and use it in GitHub Desktop.
Save MatthewRDodds/98c73939c36d98ff2bcd to your computer and use it in GitHub Desktop.
inheritance
module FooBar
def foo_bar(arg)
puts arg
super
end
end
module Foo
class Bar
include FooBar
private
def foo_bar(arg)
puts "#{arg}#{arg}#{arg}"
end
end
end
[29] pry(main)> Foo::Bar.new.send :foo_bar, 'a'
aaa
?!?!?!?!?!
# Solution
# use prepend
Foo::Bar.send :prepend, FooBar
[6] pry(main)> Foo::Bar.new.send :foo_bar, 'a'
a
aaa
# http://stackoverflow.com/questions/4470108/when-monkey-patching-a-method-can-you-call-the-overridden-method-from-the-new-i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment