123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Mocks::ObjectMethodReference Private

Do not use. This class is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
RSpec::Mocks::ClassNewMethodReference
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: RSpec::Mocks::MethodReference
Defined in: rspec-mocks/lib/rspec/mocks/method_reference.rb

Class Method Summary

Instance Attribute Summary

MethodReference - Inherited

#defined?

A method is defined if we are able to get a Method object for it.

#implemented?

A method is implemented if sending the message does not result in a NoMethodError.

#unimplemented?

Returns true if we definitively know that sending the method will result in a NoMethodError.

Instance Method Summary

MethodReference - Inherited

Class Method Details

.for(object_reference, method_name)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/method_reference.rb', line 150

def self.for(object_reference, method_name)
  if ClassNewMethodReference.applies_to?(method_name) { object_reference.when_loaded { |o| o } }
    ClassNewMethodReference.new(object_reference, method_name)
  else
    super
  end
end

Instance Method Details

#find_method(object) (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/method_reference.rb', line 168

def find_method(object)
  object.method(@method_name)
end

#method_defined?(object) ⇒ Boolean (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/method_reference.rb', line 164

def method_defined?(object)
  (class << object; self; end).method_defined?(@method_name)
end

#method_implemented?(object) ⇒ Boolean (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/method_reference.rb', line 160

def method_implemented?(object)
  object.respond_to?(@method_name, true)
end

#visibility_from(object) (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/method_reference.rb', line 172

def visibility_from(object)
  MethodReference.method_visibility_for(object, @method_name)
end