Module: Gera::CurrencyPairGenerator

Included in:
RateSource
Defined in:
app/models/concerns/gera/currency_pair_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_pairs_from_currencies(currencies) ⇒ Object



5
6
7
8
9
10
11
12
# File 'app/models/concerns/gera/currency_pair_generator.rb', line 5

def generate_pairs_from_currencies(currencies)
  currencies = currencies.map { |c| Money::Currency.find c }

  currencies
    .map { |c1| currencies.reject { |c2| c2 == c1 }.map { |c2| [c1, c2].join('/') } }
    .flatten.compact
    .map { |cp| Gera::CurrencyPair.new cp }.uniq
end