# File lib/mocha/class_method.rb, line 39 def define_new_method stubbee.__metaclass__.class_eval(%{ def #{method}(*args, &block) mocha.method_missing(:#{method}, *args, &block) end }, __FILE__, __LINE__) end
# File lib/mocha/class_method.rb, line 72 def eql?(other) return false unless (other.class == self.class) (stubbee.object_id == other.stubbee.object_id) and (method == other.method) end
# File lib/mocha/class_method.rb, line 29 def hide_original_method if method_exists?(method) begin stubbee.__metaclass__.send(:alias_method, hidden_method, method) rescue NameError # deal with nasties like ActiveRecord::Associations::AssociationProxy end end end
# File lib/mocha/class_method.rb, line 83 def method_exists?(method) symbol = method.to_sym metaclass = stubbee.__metaclass__ metaclass.public_method_defined?(symbol) || metaclass.protected_method_defined?(symbol) || metaclass.private_method_defined?(symbol) end
# File lib/mocha/class_method.rb, line 47 def remove_new_method stubbee.__metaclass__.send(:remove_method, method) end
# File lib/mocha/class_method.rb, line 51 def restore_original_method if method_exists?(hidden_method) begin 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 end end
# File lib/mocha/class_method.rb, line 14 def stub hide_original_method define_new_method end
Generated with the Darkfish Rdoc Generator 2.