# File lib/bogus/stubbing/overwrites_methods.rb, line 7 def overwrite(object, name) raise "wut?" if name == :__shadow__ return if object.is_a?(FakeObject) object.extend RecordInteractions object.extend HasOverwritenMethods method = method_by_name(object, name) copy = copy(object, name) object.__overwrite__(name, method, copy) end
# File lib/bogus/stubbing/overwrites_methods.rb, line 20 def reset(object) return if object.is_a?(FakeObject) object.__reset__ end
# File lib/bogus/stubbing/overwrites_methods.rb, line 32 def copy(object, name) method = method_by_name(object, name) return default_method(name) unless method makes_substitute_methods.stringify(method) end
# File lib/bogus/stubbing/overwrites_methods.rb, line 38 def default_method(name) "def #{name}(*args, &block); __record__(:#{name}, *args, &block); end" end
# File lib/bogus/stubbing/overwrites_methods.rb, line 28 def method_by_name(object, name) object.method(name) if object.methods.include?(name) end