module Money::Currency::Loader

Constants

DATA_PATH

Public Instance Methods

load_currencies() click to toggle source

Loads and returns the currencies stored in JSON files in the config directory.

@return [Hash]

# File lib/money/currency/loader.rb, line 9
def load_currencies
  currencies = parse_currency_file("currency_iso.json")
  currencies.merge! parse_currency_file("currency_non_iso.json")
  currencies.merge! parse_currency_file("currency_backwards_compatible.json")
end

Private Instance Methods

parse_currency_file(filename) click to toggle source
# File lib/money/currency/loader.rb, line 17
def parse_currency_file(filename)
  json = File.read("#{DATA_PATH}/#{filename}")
  json.force_encoding(::Encoding::UTF_8) if defined?(::Encoding)
  JSON.parse(json, symbolize_names: true)
end