# File lib/mocha/class_method.rb, line 55 55: def define_new_method 56: stubbee.__metaclass__.class_eval(%{ 57: def #{method}(*args, &block) 58: mocha.method_missing(:#{method}, *args, &block) 59: end 60: }, __FILE__, __LINE__) 61: end
# File lib/mocha/class_method.rb, line 36 36: def hide_original_method 37: if method_exists?(method) 38: begin 39: @original_method = stubbee._method(method) 40: if @original_method && @original_method.owner == stubbee.__metaclass__ 41: @original_visibility = :public 42: if stubbee.__metaclass__.protected_instance_methods.include?(method) 43: @original_visibility = :protected 44: elsif stubbee.__metaclass__.private_instance_methods.include?(method) 45: @original_visibility = :private 46: end 47: stubbee.__metaclass__.send(:remove_method, method) 48: end 49: rescue NameError 50: # deal with nasties like ActiveRecord::Associations::AssociationProxy 51: end 52: end 53: end
# File lib/mocha/class_method.rb, line 77 77: def matches?(other) 78: return false unless (other.class == self.class) 79: (stubbee.object_id == other.stubbee.object_id) and (method == other.method) 80: end
# File lib/mocha/class_method.rb, line 88 88: def method_exists?(method) 89: symbol = method.to_sym 90: __metaclass__ = stubbee.__metaclass__ 91: __metaclass__.public_method_defined?(symbol) || __metaclass__.protected_method_defined?(symbol) || __metaclass__.private_method_defined?(symbol) 92: end
# File lib/mocha/class_method.rb, line 28 28: def mock 29: stubbee.mocha 30: end
# File lib/mocha/class_method.rb, line 63 63: def remove_new_method 64: stubbee.__metaclass__.send(:remove_method, method) 65: end
# File lib/mocha/class_method.rb, line 32 32: def reset_mocha 33: stubbee.reset_mocha 34: end
# File lib/mocha/class_method.rb, line 67 67: def restore_original_method 68: if @original_method && @original_method.owner == stubbee.__metaclass__ 69: original_method = @original_method 70: stubbee.__metaclass__.send(:define_method, method) do |*args, &block| 71: original_method.call(*args, &block) 72: end 73: stubbee.__metaclass__.send(@original_visibility, method) 74: end 75: 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.