Class: ActionSequence::Context
- Inherits:
-
Object
- Object
- ActionSequence::Context
- Defined in:
- lib/action_sequence/context.rb
Overview
Context container to hold state for an Sequence of Actions
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
Instance Method Summary collapse
- #add_to_context!(hash) ⇒ Object
- #fail_context!(error_message) ⇒ Object
- #failed? ⇒ Boolean
- #fetch(key, default) ⇒ Object
-
#initialize(initial_context: {}) ⇒ Context
constructor
A new instance of Context.
- #success? ⇒ Boolean
Constructor Details
#initialize(initial_context: {}) ⇒ Context
Returns a new instance of Context.
11 12 13 14 |
# File 'lib/action_sequence/context.rb', line 11 def initialize(initial_context: {}) @context = initial_context @error_message = nil end |
Instance Attribute Details
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
9 10 11 |
# File 'lib/action_sequence/context.rb', line 9 def @error_message end |
Instance Method Details
#add_to_context!(hash) ⇒ Object
16 17 18 |
# File 'lib/action_sequence/context.rb', line 16 def add_to_context!(hash) context.merge!(hash) end |
#fail_context!(error_message) ⇒ Object
28 29 30 |
# File 'lib/action_sequence/context.rb', line 28 def fail_context!() @error_message = end |
#failed? ⇒ Boolean
20 21 22 |
# File 'lib/action_sequence/context.rb', line 20 def failed? !.nil? end |
#fetch(key, default) ⇒ Object
32 33 34 |
# File 'lib/action_sequence/context.rb', line 32 def fetch(key, default) context.fetch(key, default) end |
#success? ⇒ Boolean
24 25 26 |
# File 'lib/action_sequence/context.rb', line 24 def success? .nil? end |