Class: ObjectProtocol::Step
- Inherits:
-
Object
- Object
- ObjectProtocol::Step
- Defined in:
- lib/object_protocol/step.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #arguments_specified? ⇒ Boolean
-
#initialize(sender:, message:) ⇒ Step
constructor
A new instance of Step.
- #inspect ⇒ Object
- #to(receiver) ⇒ Object
- #to_rspec_matcher_failure_message_line ⇒ Object
- #with(*arguments) ⇒ Object
Constructor Details
#initialize(sender:, message:) ⇒ Step
Returns a new instance of Step.
5 6 7 8 9 10 |
# File 'lib/object_protocol/step.rb', line 5 def initialize(sender:, message:) @sender = sender = @arguments_specified = false end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
3 4 5 |
# File 'lib/object_protocol/step.rb', line 3 def arguments @arguments end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/object_protocol/step.rb', line 3 def end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
3 4 5 |
# File 'lib/object_protocol/step.rb', line 3 def receiver @receiver end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
3 4 5 |
# File 'lib/object_protocol/step.rb', line 3 def sender @sender end |
Instance Method Details
#==(other) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/object_protocol/step.rb', line 40 def ==(other) other.respond_to?(:sender) && sender == other.sender && other.respond_to?(:receiver) && receiver == other.receiver && other.respond_to?(:message) && == other. && other.respond_to?(:arguments) && arguments == other.arguments end |
#arguments_specified? ⇒ Boolean
51 52 53 |
# File 'lib/object_protocol/step.rb', line 51 def arguments_specified? @arguments_specified end |
#inspect ⇒ Object
26 27 28 |
# File 'lib/object_protocol/step.rb', line 26 def inspect "<Step[#{sender.name}, :#{message}, #{receiver.name}]>" end |
#to(receiver) ⇒ Object
12 13 14 15 16 |
# File 'lib/object_protocol/step.rb', line 12 def to(receiver) @receiver = receiver self end |
#to_rspec_matcher_failure_message_line ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/object_protocol/step.rb', line 30 def fragment_base = "#{sender.name}.sends(:#{message}).to(#{receiver.name})" if arguments_specified? "#{fragment_base}.with(#{arguments})" else fragment_base end end |
#with(*arguments) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/object_protocol/step.rb', line 18 def with(*arguments) @arguments = arguments @arguments_specified = true self end |