class RSpec::Mocks::ObjectReference
@private
def self.anonymous_module?(mod)
def self.anonymous_module?(mod) !name_of(mod) end
def self.anonymous_module?(mod)
def self.anonymous_module?(mod) name_of(mod) == "" end
def self.for(object_module_or_name, allow_direct_object_refs=false)
Returns an appropriate Object or Module reference based
def self.for(object_module_or_name, allow_direct_object_refs=false) case object_module_or_name when Module if anonymous_module?(object_module_or_name) DirectObjectReference.new(object_module_or_name) else # Use a `NamedObjectReference` if it has a name because this # will use the original value of the constant in case it has # been stubbed. NamedObjectReference.new(name_of(object_module_or_name)) end when String NamedObjectReference.new(object_module_or_name) else if allow_direct_object_refs DirectObjectReference.new(object_module_or_name) else raise ArgumentError, "Module or String expected, got #{object_module_or_name.inspect}" end end end
def self.name_of(mod)
def self.name_of(mod) MODULE_NAME_METHOD.bind(mod).call end