sprockets
https://github.com/rails/sprockets
Ruby
Rack-based asset packaging system
Sprockets::Utils#hash_reassoc
Internal: Duplicate and store key/value on new frozen hash.
Similar to Hash#store for nested frozen hashes.
hash - Hash
key_a - Object key. Use multiple keys for nested hashes.
key_b - Object key. Use multiple keys for nested hashes.
block - Receives current value at key.
Examples
config = {paths: ["/bin", "/sbin"]}.freeze
new_config = hash_reassoc(config, :paths) do |paths|
paths << "/usr/local/bin"
end
Returns duplicated frozen Hash.Edit
git clone [email protected]:rails/sprockets.git
cd sprockets
open lib/sprockets/utils.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Sprockets--Utils-hash_reassoc-for-pr
# Commit to gitgit add lib/sprockets/utils.rbgit commit -m "better docs for Sprockets::Utils#hash_reassoc"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Sprockets--Utils-hash_reassoc-for-pr
hub pull-request
# Celebrate!