Sha256: d0ae1ae7f3a884f2b4d1d8d4f912dd89f348ddeb8bbe816886907740efcb6066

Contents?: true

Size: 877 Bytes

Versions: 10

Compression:

Stored size: 877 Bytes

Contents

module ISO3166
  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.reset
    @configuration = Configuration.new
    Data.reset
  end

  def self.configure
    yield(configuration)
  end

  class Configuration
    attr_accessor :locales, :loaded_locales

    def initialize
      @locales = default_locales
      @loaded_locales = []
    end

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

    private

    def default_locales
      locales = if Object.const_defined?('I18n') && I18n.respond_to?(:available_locales)
                  I18n.available_locales
                else
                  [:en]
                end

      locales.empty? ? [:en] : locales
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
countries-4.2.0 lib/countries/configuration.rb
countries-4.1.3 lib/countries/configuration.rb
countries-4.1.2 lib/countries/configuration.rb
countries-4.1.1 lib/countries/configuration.rb
countries-4.1.0 lib/countries/configuration.rb
countries-4.0.1 lib/countries/configuration.rb
countries-4.0.0 lib/countries/configuration.rb
countries-3.1.0 lib/countries/configuration.rb
countries-3.0.1 lib/countries/configuration.rb
countries-3.0.0 lib/countries/configuration.rb