Class: Remap::Rule::Map::Required

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

Instance Method Summary collapse

Instance Method Details

#call(state, &error) ⇒ State

Represents a required mapping rule When it fails, the entire mapping is marked as failed

Parameters:

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/remap/rule/map/required.rb', line 17

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

  notice = catch :ignore do
    return fatal(state) do
      return notice(state) do
        return super
      end
    end
  end

  error[state.failure(notice)]
end