# File lib/mocha/class_method.rb, line 39 39: def define_new_method 40: stubbee.__metaclass__.class_eval(%{ 41: def #{method}(*args, &block) 42: mocha.method_missing(:#{method}, *args, &block) 43: end 44: }, __FILE__, __LINE__) 45: end
# File lib/mocha/class_method.rb, line 72 72: def eql?(other) 73: return false unless (other.class == self.class) 74: (stubbee.object_id == other.stubbee.object_id) and (method == other.method) 75: end
# File lib/mocha/class_method.rb, line 29 29: def hide_original_method 30: if method_exists?(method) 31: begin 32: stubbee.__metaclass__.send(:alias_method, hidden_method, method) 33: rescue NameError 34: # deal with nasties like ActiveRecord::Associations::AssociationProxy 35: end 36: end 37: end
# File lib/mocha/class_method.rb, line 83 83: def method_exists?(method) 84: symbol = method.to_sym 85: metaclass = stubbee.__metaclass__ 86: metaclass.public_method_defined?(symbol) || metaclass.protected_method_defined?(symbol) || metaclass.private_method_defined?(symbol) 87: end
# File lib/mocha/class_method.rb, line 25 25: def mock 26: stubbee.mocha 27: end
# File lib/mocha/class_method.rb, line 47 47: def remove_new_method 48: stubbee.__metaclass__.send(:remove_method, method) 49: end
# File lib/mocha/class_method.rb, line 51 51: def restore_original_method 52: if method_exists?(hidden_method) 53: begin 54: stubbee.__metaclass__.send(:alias_method, method, hidden_method) 55: stubbee.__metaclass__.send(:remove_method, hidden_method) 56: rescue NameError 57: # deal with nasties like ActiveRecord::Associations::AssociationProxy 58: end 59: end 60: end
# File lib/mocha/class_method.rb, line 14 14: def stub 15: hide_original_method 16: define_new_method 17: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.