Class: NxtPipeline::ErrorCallback
- Inherits:
-
Object
- Object
- NxtPipeline::ErrorCallback
- Defined in:
- lib/nxt_pipeline/error_callback.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
- #applies_to_error?(error) ⇒ Boolean
- #call(error, acc, step) ⇒ Object
- #continue_after_error? ⇒ Boolean
- #halt_on_error? ⇒ Boolean
-
#initialize(errors, halt_on_error, &callback) ⇒ ErrorCallback
constructor
A new instance of ErrorCallback.
Constructor Details
#initialize(errors, halt_on_error, &callback) ⇒ ErrorCallback
Returns a new instance of ErrorCallback.
3 4 5 6 7 |
# File 'lib/nxt_pipeline/error_callback.rb', line 3 def initialize(errors, halt_on_error, &callback) @errors = errors.any? ? errors : [StandardError] @halt_on_error = halt_on_error @callback = callback end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
9 10 11 |
# File 'lib/nxt_pipeline/error_callback.rb', line 9 def callback @callback end |
#errors ⇒ Object
Returns the value of attribute errors.
9 10 11 |
# File 'lib/nxt_pipeline/error_callback.rb', line 9 def errors @errors end |
Instance Method Details
#applies_to_error?(error) ⇒ Boolean
19 20 21 |
# File 'lib/nxt_pipeline/error_callback.rb', line 19 def applies_to_error?(error) (error.class.ancestors & errors).any? end |
#call(error, acc, step) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/nxt_pipeline/error_callback.rb', line 23 def call(error, acc, step) args = [error, acc, step] args = args.take(callback.arity) unless callback.arity.negative? callback.call(*args) end |
#continue_after_error? ⇒ Boolean
15 16 17 |
# File 'lib/nxt_pipeline/error_callback.rb', line 15 def continue_after_error? !halt_on_error? end |
#halt_on_error? ⇒ Boolean
11 12 13 |
# File 'lib/nxt_pipeline/error_callback.rb', line 11 def halt_on_error? @halt_on_error end |