Method: HashMath::Unpivot#expand

Defined in:
lib/hash_math/unpivot.rb

#expand(hash) ⇒ Object

The main method for this class that performs the un-pivoting and hash expansion. Pass in a hash and it will return an array of hashes.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hash_math/unpivot.rb', line 30

def expand(hash)
  return [hash] unless pivot_set.any?

  all_combinations = pivot_set.expand(hash)

  products = all_combinations.inject(all_combinations.shift) do |memo, array|
    memo.product(array)
  end

  recombine(products)
end