class Rudux::Combined
Public Class Methods
new(hash)
click to toggle source
# File lib/rudux/combined.rb, line 3 def initialize hash @hash = hash end
Public Instance Methods
reduce(state, action)
click to toggle source
# File lib/rudux/combined.rb, line 7 def reduce state, action @hash.keys.map do |key| reducer = @hash[key] if state.is_a? Hash substate = state[key] else substate = state.send(key) end reduced = reducer.reduce(substate, action) Hash[key, reduced] end.reduce({}, &:merge!) end