Class: Hash
Instance Method Summary collapse
Instance Method Details
#reverse_merge(other) ⇒ Object
17 18 19 |
# File 'lib/ruco/core_ext/hash.rb', line 17 def reverse_merge(other) other.merge(self) end |
#slice(*keys, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ruco/core_ext/hash.rb', line 6 def slice(*keys, &block) if block each do |key, val| boolean = block.call(key, val) keys << key if boolean end end hash = self keys.inject({}){|returned, key| returned.update key => hash[key]} end |