Class: Remap::Rule::Each
- Inherits:
-
Unit
- Object
- Unit
- Remap::Rule::Each
- Defined in:
- lib/remap/rule/each.rb
Overview
Iterates over a rule, even if the rule is not a collection
Instance Method Summary collapse
-
#call(state, &error) ⇒ State<Enumerable>
Iterates over state and passes each value to rule Restores element, key & index before returning state.
- #rule ⇒ Rule
Instance Method Details
#call(state, &error) ⇒ State<Enumerable>
Iterates over state and passes each value to rule Restores element, key & index before returning state
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/remap/rule/each.rb', line 25 def call(state, &error) unless error raise ArgumentError, "Each#call(state, &error) requires a block" end state.map do |inner_state| rule.call(inner_state) do |failure| return error[failure] end end end |