Sha256: dae6f5ec809498998cfa53b0c0fece581d7aafe7e5406d374075ed48835750a0

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

module WorldFlags
  module Util
    module Config
      attr_accessor :auto_select, :raise_error
      attr_accessor :default_code, :default_locale

      def reset!
        raise_error_off!
        auto_select_off!

        self.countries = nil
        self.countries_map = nil

        self.languages_map = nil
        self.languages = nil
      end

      def default_code_used
        WorldFlags.default_code || :us
      end

      def default_locale_used
        WorldFlags.default_locale || I18n.locale
      end

      def available_locales
        @available_locales ||= I18n.available_locales unless I18n.available_locales.blank?
        @available_locales ||= default_locales
      end

      def available_locales= *list
        raise ArgumentError, "Must be a list of locales, was #{list}" if list.empty?
        @available_locales = list.flatten
      end

      def default_locales
        ['en', 'fr', 'es', 'ru']
      end

      def auto_select?
        auto_select
      end

      def auto_select!
        @auto_select = true
      end

      def auto_select_off!
        @auto_select = true
      end

      def raise_error?
        @raise_error
      end

      def raise_error!
        @raise_error = true
      end

      def raise_error_off!
        @raise_error = false
      end      
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
world-flags-0.4.2 lib/world_flags/util/config.rb
world-flags-0.4.1 lib/world_flags/util/config.rb
world-flags-0.4.0 lib/world_flags/util/config.rb
world-flags-0.3.6 lib/world_flags/util/config.rb
world-flags-0.3.5 lib/world_flags/util/config.rb