Class: Morpher::Transform::Sequence
- Inherits:
-
Morpher::Transform
- Object
- Morpher::Transform
- Morpher::Transform::Sequence
- Defined in:
- lib/morpher/transform.rb
Overview
Sequence of transformations
Instance Method Summary collapse
-
#call(input) ⇒ Either<Error, Object>
Apply transformation to input.
-
#seq(transform) ⇒ Transform
Build sequence.
Methods inherited from Morpher::Transform
Instance Method Details
#call(input) ⇒ Either<Error, Object>
Apply transformation to input
459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/morpher/transform.rb', line 459 def call(input) current = input steps.each_with_index do |step, index| current = step.call(current).from_right do |error| return failure(error(cause: Index.wrap(error, index), input: input)) end end success(current) end |
#seq(transform) ⇒ Transform
Build sequence
450 451 452 |
# File 'lib/morpher/transform.rb', line 450 def seq(transform) self.class.new(steps + [transform]) end |