Class: RSpec::Mocks::AnyInstance::FluentInterfaceProxy
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/proxy.rb
Overview
Delegates messages to each of the given targets in order to provide the fluent interface that is available off of message expectations when dealing with ‘any_instance`.
‘targets` will typically contain 1 of the `AnyInstance::Recorder` return values and N `MessageExpectation` instances (one per instance of the `any_instance` klass).
Instance Method Summary collapse
-
#initialize(targets) ⇒ FluentInterfaceProxy
constructor
A new instance of FluentInterfaceProxy.
- #method_missing(*args, &block) ⇒ Object
- #respond_to?(method_name, include_private = false) ⇒ Boolean
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(targets) ⇒ FluentInterfaceProxy
Returns a new instance of FluentInterfaceProxy.
95 96 97 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/proxy.rb', line 95 def initialize(targets) @targets = targets end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
109 110 111 112 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/proxy.rb', line 109 def method_missing(*args, &block) return_values = @targets.map { |t| t.__send__(*args, &block) } FluentInterfaceProxy.new(return_values) end |
Instance Method Details
#respond_to?(method_name, include_private = false) ⇒ Boolean
104 105 106 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/proxy.rb', line 104 def respond_to?(method_name, include_private=false) super || @targets.first.respond_to?(method_name, include_private) end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
100 101 102 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/proxy.rb', line 100 def respond_to_missing?(method_name, include_private=false) super || @targets.first.respond_to?(method_name, include_private) end |