Sha256: 7e3aad41d0604ae7ad7f2efa04dfb7962ee1fa07b2743197d2cf588c5e6165c7

Contents?: true

Size: 759 Bytes

Versions: 3

Compression:

Stored size: 759 Bytes

Contents

module FastGettext
  module Storage
    [:text_domain,:available_locales].each do |method|
      define_method method do
        thread_store(method)
      end
      define_method "#{method}=" do |value|
        write_thread_store(method,value)
      end
    end

    @@text_domains={}
    def text_domains
      @@text_domains
    end

    def locale
      thread_store(:locale) || (available_locales||[]).first || 'en'
    end

    def locale=(value)
      write_thread_store(:locale,value) if not available_locales or available_locales.include?(value)
    end

    private

    def thread_store(key)
      Thread.current["FastGettext.#{key}"]
    end

    def write_thread_store(key,value)
      Thread.current["FastGettext.#{key}"]=value
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grosser-fast_gettext-0.2.2 lib/fast_gettext/storage.rb
grosser-fast_gettext-0.2.3 lib/fast_gettext/storage.rb
grosser-fast_gettext-0.2.4 lib/fast_gettext/storage.rb