module Sprockets::Utils
def hash_reassoc(hash, *keys, &block)
end
paths << "/usr/local/bin"
new_config = hash_reassoc(config, :paths) do |paths|
config = {paths: ["/bin", "/sbin"]}.freeze
Examples
block - Receives current value at key.
key - Object keys. Use multiple keys for nested hashes.
hash - Hash
Similar to Hash#store for nested frozen hashes.
Internal: Duplicate and store key/value on new frozen hash.
def hash_reassoc(hash, *keys, &block) if keys.size == 1 hash_reassoc1(hash, keys[0], &block) else hash_reassoc1(hash, keys[0]) do |value| hash_reassoc(value, *keys[1..-1], &block) end end end