Created
March 7, 2013 01:22
-
-
Save mattetti/5104790 to your computer and use it in GitHub Desktop.
Ruby 2.0 module prepend example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @mattetti...It's very simple and understandable example.