Skip to content

Instantly share code, notes, and snippets.

@VelizarHristov
Last active October 11, 2015 17:25
Show Gist options
  • Save VelizarHristov/ab6e11db75f4c41aea95 to your computer and use it in GitHub Desktop.
Save VelizarHristov/ab6e11db75f4c41aea95 to your computer and use it in GitHub Desktop.
# This is outside my control
class Foo
def self.bar
'Original'
end
end
Foo.bar # 'Original'
Foo.singleton_class.send(:alias_method, :old_bar, :bar)
def Foo.bar
'Mock'
end
Foo.bar # 'Mock'
Foo.singleton_class.send(:alias_method, :bar, :old_bar)
Foo.bar # 'Original'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment