Class: Philiprehberger::Pipe::Step
- Inherits:
-
Object
- Object
- Philiprehberger::Pipe::Step
- Defined in:
- lib/philiprehberger/pipe/step.rb
Instance Attribute Summary collapse
-
#callable ⇒ Object
readonly
Returns the value of attribute callable.
-
#guard_if ⇒ Object
readonly
Returns the value of attribute guard_if.
-
#guard_unless ⇒ Object
readonly
Returns the value of attribute guard_unless.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #execute(value) ⇒ Object
-
#initialize(callable:, name: nil, type: :transform, guard_if: nil, guard_unless: nil) ⇒ Step
constructor
A new instance of Step.
Constructor Details
#initialize(callable:, name: nil, type: :transform, guard_if: nil, guard_unless: nil) ⇒ Step
Returns a new instance of Step.
8 9 10 11 12 13 14 |
# File 'lib/philiprehberger/pipe/step.rb', line 8 def initialize(callable:, name: nil, type: :transform, guard_if: nil, guard_unless: nil) @callable = callable @name = name @type = type @guard_if = guard_if @guard_unless = guard_unless end |
Instance Attribute Details
#callable ⇒ Object (readonly)
Returns the value of attribute callable.
6 7 8 |
# File 'lib/philiprehberger/pipe/step.rb', line 6 def callable @callable end |
#guard_if ⇒ Object (readonly)
Returns the value of attribute guard_if.
6 7 8 |
# File 'lib/philiprehberger/pipe/step.rb', line 6 def guard_if @guard_if end |
#guard_unless ⇒ Object (readonly)
Returns the value of attribute guard_unless.
6 7 8 |
# File 'lib/philiprehberger/pipe/step.rb', line 6 def guard_unless @guard_unless end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/philiprehberger/pipe/step.rb', line 6 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/philiprehberger/pipe/step.rb', line 6 def type @type end |
Instance Method Details
#execute(value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/philiprehberger/pipe/step.rb', line 16 def execute(value) return value if skipped?(value) result = callable.call(value) type == :tee ? value : result rescue PipeError, Halted raise rescue StandardError => e raise PipeError.new(e., step_name: name, original_error: e) end |