Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/awis/hash.rb,
lib/awis/utils/hash.rb
Instance Method Summary collapse
- #array_slice_merge!(key, array, count) ⇒ Object
- #deep_find(key, object = self, found = nil) ⇒ Object
Instance Method Details
#array_slice_merge!(key, array, count) ⇒ Object
4 5 6 |
# File 'lib/awis/hash.rb', line 4 def array_slice_merge!(key, array, count) self[key] = array.each_slice(count).collect { |e| e.reduce({}, :merge) } end |
#deep_find(key, object = self, found = nil) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/awis/hash.rb', line 8 def deep_find(key, object = self, found = nil) return object[key] if object.respond_to?(:key?) && object.key?(key) return found unless object.is_a?(Enumerable) object.find { |*a| found = deep_find(key, a.last) } found end |