Class: Remap::Rule::Map::Optional Private

Inherits:
Required
  • Object
show all
Defined in:
lib/remap/rule/map/optional.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Represents an optional mapping rule When the mapping fails, the value is ignored

Examples:

Map [:name] to [:nickname]

map = Map::Optional.call({
  backtrace: caller,
  path: {
    input: [:name],
    output: [:nickname]
  }
})

state = Remap::State.call({
  name: "John"
})

output = map.call(state) do |failure|
  raise failure.exception(caller)
end

output.fetch(:value) # => { nickname: "John" }

See Also:



33
34
35
# File 'lib/remap/rule/map/optional.rb', line 33

def call(state)
  catch_ignored(state) { super(_1) }
end