Class: Remap::Rule::Each
- Inherits:
-
Value
- Object
- Value
- Remap::Rule::Each
- Defined in:
- lib/remap/rule/each.rb
Instance Method Summary collapse
-
#call(state) ⇒ State
Iterates over state and passes each value to rule Restores path before returning state.
Instance Method Details
#call(state) ⇒ State
Iterates over state and passes each value to rule Restores path before returning state
# @example
class Mapper < Remap::Base
define do
map :people, to: :names do
each do
map(:name)
end
end
end
end
Mapper.call(people: [{ name: "John" }, { name: "Jane" }]) # => { names: ["John", "Jane"] }
30 31 32 33 34 |
# File 'lib/remap/rule/each.rb', line 30 def call(state) state.map do |state| rule.call(state) end end |