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

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

Instance Method Summary collapse

Instance Method Details

#call(state, &error) ⇒ State

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

Parameters:

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/remap/rule/map/optional.rb', line 15

def call(state, &error)
  unless error
    raise ArgumentError, "map.call(state, &error) requires a block"
  end

  fatal(state) do
    return ignore(state) do
      return notice(state) do
        return super
      end
    end
  end
end