Skip to content

Instantly share code, notes, and snippets.

@pedronsouza
Created March 26, 2013 22:22
Show Gist options
  • Save pedronsouza/5249857 to your computer and use it in GitHub Desktop.
Save pedronsouza/5249857 to your computer and use it in GitHub Desktop.
Refinements on Ruby 2.0
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