Created
February 28, 2013 08:02
-
-
Save lsegal/5055063 to your computer and use it in GitHub Desktop.
On a positive note, AOP with mixins just got way simpler in Ruby 2:
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
module Helper | |
def help | |
puts "Hello," | |
super | |
end | |
end | |
class Foo | |
def help | |
puts "Do you need help?" | |
end | |
end | |
Foo.send(:prepend, Helper) | |
Foo.new.help | |
__DATA__ | |
Prints: | |
Hello, | |
Do you need help? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
prepend
is rad.(I also continue to love Ruby’s
__DATA__
declaration.)