Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save styx/9286220 to your computer and use it in GitHub Desktop.
Save styx/9286220 to your computer and use it in GitHub Desktop.
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