Skip to content

Instantly share code, notes, and snippets.

@mattetti
Created March 7, 2013 01:22
Show Gist options
  • Save mattetti/5104790 to your computer and use it in GitHub Desktop.
Save mattetti/5104790 to your computer and use it in GitHub Desktop.
Ruby 2.0 module prepend example
# Not our code
class Action
def start
"just do it"
end
end
# The module including our modifying code
module RubyIt
def start
super + " better with Ruby!"
end
end
class Action
prepend RubyIt
end
p Action.new.start
# -> "just do it better with Ruby!"
@karuppasamy
Copy link

Thanks @mattetti...It's very simple and understandable example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment