Skip to content

Instantly share code, notes, and snippets.

@eliav-lavi
Created October 16, 2018 07:26
Show Gist options
  • Select an option

  • Save eliav-lavi/46bec8081cb979b7e63e19b96f992728 to your computer and use it in GitHub Desktop.

Select an option

Save eliav-lavi/46bec8081cb979b7e63e19b96f992728 to your computer and use it in GitHub Desktop.
Wrapping methods with prepend
module FooWrapper
def bar
puts "this will happen before the real bar!"
super
end
end
class Foo
prepend FooWrapper
def bar
:bar_return_value
end
end
# Foo.new.bar
# this will happen before the real bar!
# => :bar_return_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment