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
2 3 4 |
# File 'lib/awis/hash.rb', line 2 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
6 7 8 9 10 11 12 |
# File 'lib/awis/hash.rb', line 6 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 |