Module: Remap::Operation

Includes:
State
Included in:
Base, Mapper::Binary
Defined in:
lib/remap/operation.rb

Constant Summary

Constants included from State

State::Schema

Instance Method Summary collapse

Methods included from State

#state

Instance Method Details

#call(input, **options, &error) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/remap/operation.rb', line 8

def call(input, **options, &error)
  new_state = state(input, options: options, mapper: self)

  new_state = call!(new_state) do |failure|
    return Failure.new(reasons: failure, problems: new_state.problems)
  end

  if error
    return error[new_state]
  end

  value = new_state.fetch(:value) do
    return Failure.new(reasons: new_state.failure("No mapped data"), problems: new_state.problems)
  end

  Success.new(problems: new_state.problems, result: value)
end