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
#array, #maybe, #slug, #to_proc
Instance Method Details
#call(input) ⇒ Either<Error, Object>
Apply transformation to input
465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/morpher/transform.rb', line 465 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
456 457 458 |
# File 'lib/morpher/transform.rb', line 456 def seq(transform) self.class.new(steps + [transform]) end |