Class: BusinessPipeline::Context
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- BusinessPipeline::Context
- Defined in:
- lib/business_pipeline/context.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fail ⇒ Object
- #fail!(additional_context = {}) ⇒ Object
- #failure? ⇒ Boolean
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #succeed!(additional_context = {}) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
11 12 13 14 |
# File 'lib/business_pipeline/context.rb', line 11 def initialize(*) super @failure = false end |
Class Method Details
.build(context = {}) ⇒ Object
7 8 9 |
# File 'lib/business_pipeline/context.rb', line 7 def self.build(context = {}) context.is_a?(self) ? context : new(context) end |
Instance Method Details
#fail ⇒ Object
16 17 18 |
# File 'lib/business_pipeline/context.rb', line 16 def fail @failure = true end |
#fail!(additional_context = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/business_pipeline/context.rb', line 20 def fail!(additional_context = {}) update!(additional_context) self.fail throw :early_stop, self end |
#failure? ⇒ Boolean
26 27 28 |
# File 'lib/business_pipeline/context.rb', line 26 def failure? !!@failure end |
#succeed!(additional_context = {}) ⇒ Object
30 31 32 33 |
# File 'lib/business_pipeline/context.rb', line 30 def succeed!(additional_context = {}) update!(additional_context) throw :early_stop, self end |
#success? ⇒ Boolean
35 36 37 |
# File 'lib/business_pipeline/context.rb', line 35 def success? !failure? end |