class RSpec::SleepingKingStudios::Deferred::Call
Value object representing a deferred call to a method.
Attributes
@return [Array] the arguments to pass to the method.
@return [Proc] the block to pass to the method.
@return [Hash] the keywords to pass to the method.
@return [String, Symbol] the name of the method to call.
Public Class Methods
Source
# 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
@param method_name
[String, Symbol] the name of the method to call. @param arguments [Array] the arguments to pass to the method. @param keywords [Hash] the keywords to pass to the method. @param block [Proc] the block to pass to the method.
Public Instance Methods
Source
# 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
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.
@param other [Object] the object to compare.
@return [Boolean] true if the other matches the deferred call; otherwise
false.
Source
# File lib/rspec/sleeping_king_studios/deferred/call.rb, line 60 def call(receiver) receiver.send(method_name, *arguments, **keywords, &block) end
Invokes the deferred method call on the receiver.
@param receiver [Object] the receiver for the method call.
@return [Object] the returned value of the method call.
Private Instance Methods
Source
# File lib/rspec/sleeping_king_studios/deferred/call.rb, line 66 def tools SleepingKingStudios::Tools::Toolbelt.instance end
Source
# File lib/rspec/sleeping_king_studios/deferred/call.rb, line 70 def validate_parameters! tools.assertions.validate_name(method_name, as: 'method_name') end