Permalink
Browse files

Merge branch 'master' into tinogomes/master

  • Loading branch information...
2 parents 6e04385 + d4a1938 commit 492273272d97ff084edd40f9f16c67ea61fc68fe @floehopper floehopper committed Jan 29, 2009
Showing with 8 additions and 6 deletions.
  1. +4 −3 lib/mocha/any_instance_method.rb
  2. +4 −3 lib/mocha/class_method.rb
@@ -17,7 +17,7 @@ def mock
def hide_original_method
if method_exists?(method)
begin
- stubbee.class_eval("alias_method :#{hidden_method}, :#{method}", __FILE__, __LINE__)
+ stubbee.send(:alias_method, hidden_method, method)
rescue NameError
# deal with nasties like ActiveRecord::Associations::AssociationProxy
end
@@ -29,13 +29,14 @@ def define_new_method
end
def remove_new_method
- stubbee.class_eval("remove_method :#{method}", __FILE__, __LINE__)
+ stubbee.send(:remove_method, method)
end
def restore_original_method
if method_exists?(hidden_method)
begin
- stubbee.class_eval("alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}", __FILE__, __LINE__)
+ stubbee.send(:alias_method, method, hidden_method)
+ stubbee.send(:remove_method, hidden_method)
rescue NameError
# deal with nasties like ActiveRecord::Associations::AssociationProxy
end
@@ -29,7 +29,7 @@ def mock
def hide_original_method
if method_exists?(method)
begin
- stubbee.__metaclass__.class_eval("alias_method :#{hidden_method}, :#{method}", __FILE__, __LINE__)
+ stubbee.__metaclass__.send(:alias_method, hidden_method, method)
rescue NameError
# deal with nasties like ActiveRecord::Associations::AssociationProxy
end
@@ -41,13 +41,14 @@ def define_new_method
end
def remove_new_method
- stubbee.__metaclass__.class_eval("remove_method :#{method}", __FILE__, __LINE__)
+ stubbee.__metaclass__.send(:remove_method, method)
end
def restore_original_method
if method_exists?(hidden_method)
begin
- stubbee.__metaclass__.class_eval("alias_method :#{method}, :#{hidden_method}; remove_method :#{hidden_method}", __FILE__, __LINE__)
+ stubbee.__metaclass__.send(:alias_method, method, hidden_method)
+ stubbee.__metaclass__.send(:remove_method, hidden_method)
rescue NameError
# deal with nasties like ActiveRecord::Associations::AssociationProxy
end

0 comments on commit 4922732

Please sign in to comment.