Created
March 26, 2013 22:22
-
-
Save pedronsouza/5249857 to your computer and use it in GitHub Desktop.
Refinements on Ruby 2.0
This file contains hidden or 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
class String | |
def say_hi | |
"Hi #{self}!" | |
end | |
end | |
class MinhaClasse | |
puts "Pedro".say_hi | |
end | |
# Com o Refinments | |
module StringExtensions | |
refine String do | |
def say_hi | |
"Hi #{self}!" | |
end | |
end | |
end | |
class MinhaClasse | |
using StringExtensions | |
puts "Pedro".say_hi | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment