Created
October 23, 2014 03:50
-
-
Save kavinderd/d7d6e6694897200735b0 to your computer and use it in GitHub Desktop.
Refinement Gotchas From Metaprogramming Ruby Book
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 MyClass | |
def my_method | |
"original my_method" | |
end | |
def another_method | |
my_method | |
end | |
end | |
module MyClassRefinement | |
refine MyClass do | |
def my_method | |
"refined my_method" | |
end | |
end | |
end | |
using MyClassRefinement | |
puts MyClass.new.my_method #=> "refined my_method" | |
puts MyClass.new.another_method #=> "original my_method" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment