Created
February 24, 2014 07:10
-
-
Save tagomoris/9183222 to your computer and use it in GitHub Desktop.
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 Foo | |
def self.foo | |
"foo" | |
end | |
def foo | |
"ifoo" | |
end | |
def true_foo | |
Foo.foo | |
end | |
end | |
module Interceptor | |
refine Foo.singleton_class do | |
def foo | |
"bar" | |
end | |
end | |
refine Foo do | |
def foo | |
"ibar" | |
end | |
end | |
end | |
using Interceptor | |
p Foo.foo # "bar" | |
p Foo.new.foo # "ibar" | |
p Foo.new.true_foo # "foo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment