Class: HashSieve::TemplateExtractor::Array

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_sieve/template_extractor/array.rb

Class Method Summary collapse

Class Method Details

.extract(array) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/hash_sieve/template_extractor/array.rb', line 6

def self.extract(array)
  array.reduce({}) do |attributes, element|
    HashSieve::TemplateExtractor.extract(element).each do |candidate_key, candidate_value|
      has_no_candidate_key = attributes[candidate_key].nil?
      attributes[candidate_key] = candidate_value if !candidate_value.empty? || has_no_candidate_key
    end
    attributes
  end
end