Class: RSpec::Mocks::ObjectReference Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rspec-mocks/lib/rspec/mocks/object_reference.rb |
Constant Summary
-
MODULE_NAME_METHOD =
# File 'rspec-mocks/lib/rspec/mocks/object_reference.rb', line 47Module.instance_method(:name)
Class Method Summary
-
.for(object_module_or_name, allow_direct_object_refs = false)
Internal use only
Returns an appropriate Object or Module reference based on the given argument.
-
.anonymous_module?(mod) ⇒ Boolean
private
Internal use only
1.8.7.
- .name_of(mod) private Internal use only
Class Method Details
.anonymous_module?(mod) ⇒ Boolean
(private)
1.8.7
# File 'rspec-mocks/lib/rspec/mocks/object_reference.rb', line 35
def self.anonymous_module?(mod) !name_of(mod) end
.for(object_module_or_name, allow_direct_object_refs = false)
Returns an appropriate Object or Module reference based on the given argument.
# File 'rspec-mocks/lib/rspec/mocks/object_reference.rb', line 7
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
.name_of(mod) (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/object_reference.rb', line 41
def self.name_of(mod) MODULE_NAME_METHOD.bind(mod).call end