Module | Cms::Extensions::Hash |
In: |
lib/cms/extensions/hash.rb
|
Returns a copy of the hash without the keys passed as arguments
# File lib/cms/extensions/hash.rb, line 5 5: def except(*args) 6: reject {|k,v| args.include?(k) } 7: end
This takes a list of keys and returns a new hash containing the key/values that match the keys passed in. This will also remove the keys from this hash
# File lib/cms/extensions/hash.rb, line 12 12: def extract!(*keys) 13: keys.inject({}) do |hash, key| 14: hash[key] = delete(key) if has_key?(key) 15: hash 16: end 17: end