Class: Bogus::OverwritesMethods

Inherits:
Object
  • Object
show all
Extended by:
Takes
Defined in:
lib/bogus/stubbing/overwrites_methods.rb

Instance Method Summary collapse

Methods included from Takes

takes

Instance Method Details

#overwrite(object, name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bogus/stubbing/overwrites_methods.rb', line 7

def overwrite(object, name)
  raise "wut?" if name == :__shadow__
  return if already_delegates_to_shadow?(object, name)

  object.extend RecordInteractions
  object.extend HasOverwritenMethods

  method = method_by_name(object, name)
  copy = copy(object, name)

  object.__overwrite__(name, method, copy)
end

#reset(object) ⇒ Object



20
21
22
23
24
# File 'lib/bogus/stubbing/overwrites_methods.rb', line 20

def reset(object)
  return if object.is_a?(FakeObject)

  object.__reset__
end