class Sprockets::Bundle
def self.process_bundle_reducers(assets, reducers)
reducers - Array of [initial, reducer_proc] pairs
assets - Array of Assets
metadata Hash.
Internal: Run bundle reducers on set of Assets producing a reduced
def self.process_bundle_reducers(assets, reducers) initial = {} reducers.each do |k, (v, _)| initial[k] = v if !v.nil? end assets.reduce(initial) do |h, asset| reducers.each do |k, (_, block)| value = k == :data ? asset.source : asset.metadata[k] if h.key?(k) if !value.nil? h[k] = block.call(h[k], value) end else h[k] = value end end h end end