class RSpec::Mocks::Space

@api private

def any_instance_recorder_for(klass)

def any_instance_recorder_for(klass)
  print_out_of_example_deprecation if outside_example
  id = klass.__id__
  any_instance_recorders.fetch(id) do
    any_instance_recorders[id] = AnyInstance::Recorder.new(klass)
  end
end

def expectation_ordering

def expectation_ordering
  @expectation_ordering ||= OrderGroup.new
end

def id_for(object)

def id_for(object)
  id = object.__id__
  return id if object.equal?(::ObjectSpace._id2ref(id))
  # this suggests that object.__id__ is proxying through to some wrapped object
  object.instance_eval do
    @__id_for_rspec_mocks_space ||= ::SecureRandom.uuid
  end
end

def id_for(object)

def id_for(object)
  object.__id__
end

def initialize

def initialize
  @proxies                 = {}
  @any_instance_recorders  = {}
  self.outside_example     = true
end

def print_out_of_example_deprecation

def print_out_of_example_deprecation
  RSpec.deprecate("Using rspec-mocks doubles or partial doubles outside the per-test lifecycle (such as in a `before(:all)` hook)")
end

def proxies_of(klass)

def proxies_of(klass)
  proxies.values.select { |proxy| klass === proxy.object }
end

def proxy_for(object)

def proxy_for(object)
  print_out_of_example_deprecation if outside_example
  id = id_for(object)
  proxies.fetch(id) do
    proxies[id] = case object
                  when NilClass   then ProxyForNil.new
                  when TestDouble then object.__build_mock_proxy
                  else
                    Proxy.new(object)
                  end
  end
end

def registered?(object)

def registered?(object)
  proxies.has_key?(id_for object)
end

def reset_all

def reset_all
  ConstantMutator.reset_all
  proxies.each_value do |object|
    object.reset
  end
  proxies.clear
  any_instance_recorders.each_value do |recorder|
    recorder.stop_all_observation!
  end
  any_instance_recorders.clear
  expectation_ordering.clear
end

def verify_all

def verify_all
  proxies.each_value do |object|
    object.verify
  end
  any_instance_recorders.each_value do |recorder|
    recorder.verify
  end
end