Module: Marshal

Defined in:
lib/rspec/mocks/extensions/marshal.rb

Class Method Summary collapse

Class Method Details

.dump_with_mocks(*args) ⇒ Object Also known as: dump



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rspec/mocks/extensions/marshal.rb', line 5

def dump_with_mocks(*args)
  object = args.shift
  return dump_without_mocks(*args.unshift(object)) unless object.instance_variable_defined?(:@mock_proxy)

  mp = object.instance_variable_get(:@mock_proxy)
  object.send(:remove_instance_variable, :@mock_proxy)

  begin
    dump_without_mocks(*args.unshift(object.dup))
  ensure
    object.instance_variable_set(:@mock_proxy,mp)
  end
end