Class: RSpec::SleepingKingStudios::Deferred::Call
- Inherits:
-
Object
- Object
- RSpec::SleepingKingStudios::Deferred::Call
- Defined in:
- lib/rspec/sleeping_king_studios/deferred/call.rb
Overview
Value object representing a deferred call to a method.
Direct Known Subclasses
RSpec::SleepingKingStudios::Deferred::Calls::Example, RSpec::SleepingKingStudios::Deferred::Calls::ExampleGroup, RSpec::SleepingKingStudios::Deferred::Calls::Hook, RSpec::SleepingKingStudios::Deferred::Calls::IncludedExamples, RSpec::SleepingKingStudios::Deferred::Calls::SharedExamples
Instance Attribute Summary collapse
-
#arguments ⇒ Array
readonly
The arguments to pass to the method.
-
#block ⇒ Proc
readonly
The block to pass to the method.
-
#keywords ⇒ Hash
readonly
The keywords to pass to the method.
-
#method_name ⇒ String, Symbol
readonly
The name of the method to call.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares the other object with the deferred call.
-
#call(receiver) ⇒ Object
Invokes the deferred method call on the receiver.
-
#initialize(method_name, *arguments, **keywords, &block) ⇒ Call
constructor
A new instance of Call.
Constructor Details
#initialize(method_name, *arguments, **keywords, &block) ⇒ Call
Returns a new instance of Call.
14 15 16 17 18 19 20 21 |
# File 'lib/rspec/sleeping_king_studios/deferred/call.rb', line 14 def initialize(method_name, *arguments, **keywords, &block) @method_name = method_name @arguments = arguments @keywords = keywords @block = block validate_parameters! end |
Instance Attribute Details
#arguments ⇒ Array (readonly)
Returns the arguments to pass to the method.
24 25 26 |
# File 'lib/rspec/sleeping_king_studios/deferred/call.rb', line 24 def arguments @arguments end |
#block ⇒ Proc (readonly)
Returns the block to pass to the method.
27 28 29 |
# File 'lib/rspec/sleeping_king_studios/deferred/call.rb', line 27 def block @block end |
#keywords ⇒ Hash (readonly)
Returns the keywords to pass to the method.
30 31 32 |
# File 'lib/rspec/sleeping_king_studios/deferred/call.rb', line 30 def keywords @keywords end |
#method_name ⇒ String, Symbol (readonly)
Returns the name of the method to call.
33 34 35 |
# File 'lib/rspec/sleeping_king_studios/deferred/call.rb', line 33 def method_name @method_name end |
Instance Method Details
#==(other) ⇒ Boolean
Compares the other object with the deferred call.
Returns true if and only if:
- The other object is an instance of Deferred::Call.
- The other object's method name and type match the deferred call.
- The other object's arguments, keywords, and block all match the deferred call.
47 48 49 50 51 52 53 |
# File 'lib/rspec/sleeping_king_studios/deferred/call.rb', line 47 def ==(other) other.class == self.class && other.method_name == method_name && other.arguments == arguments && other.keywords == keywords && other.block == block end |
#call(receiver) ⇒ Object
Invokes the deferred method call on the receiver.
60 61 62 |
# File 'lib/rspec/sleeping_king_studios/deferred/call.rb', line 60 def call(receiver) receiver.send(method_name, *arguments, **keywords, &block) end |