Class: ISO3166::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/countries/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



24
25
26
# File 'lib/countries/configuration.rb', line 24

def initialize
  @loaded_locales = []
end

Instance Attribute Details

#loaded_localesObject

Returns the value of attribute loaded_locales.



22
23
24
# File 'lib/countries/configuration.rb', line 22

def loaded_locales
  @loaded_locales
end

Instance Method Details

#enable_currency_extension!Object

Enables the integration with the Money gem

Please note that it requires you to add “money” gem to your gemfile.

gem "money", "~> 6.9"

WARNING if you have a top level class named Money you will conflict with this gem.

Examples:

c = ISO3166::Country['us']
c.currency.iso_code # => 'USD'
c.currency.name # => 'United States Dollar'
c.currency.symbol # => '$'


53
54
55
56
# File 'lib/countries/configuration.rb', line 53

def enable_currency_extension!
  require 'countries/country/currency_methods'
  ISO3166::Country.prepend(ISO3166::CountryCurrencyMethods)
end

#localesObject



28
29
30
# File 'lib/countries/configuration.rb', line 28

def locales
  @locales ||= default_locales
end

#locales=(value) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/countries/configuration.rb', line 32

def locales=(value)
  if value.is_a?(Array)
    @locales = value.map(&:to_sym).uniq
  else
    raise ArgumentError, "Expected an Array of locales, got #{value.class}"
  end
end