module Sprockets::Utils
def hash_reassoc1(hash, key)
key - Object key
hash - Hash
Seperated for recursive calls, always use hash_reassoc(hash, *keys).
Internal: Duplicate and store key/value on new frozen hash.
def hash_reassoc1(hash, key) hash = hash.dup if hash.frozen? old_value = hash[key] old_value = old_value.dup if duplicable?(old_value) new_value = yield old_value new_value.freeze if duplicable?(new_value) hash.store(key, new_value) hash.freeze end