Sha256: 102fe3429d1fbe84065b3f40489473851a94441c460a6f3315618a3ca59c2e04

Contents?: true

Size: 567 Bytes

Versions: 60

Compression:

Stored size: 567 Bytes

Contents

module SimpleForm
  # A lot of configuration values are retrived from I18n,
  # like boolean collection, required string. This module provides
  # caching facility to speed up form construction.
  module I18nCache
    def i18n_cache(key)
      get_i18n_cache(key)[I18n.locale] ||= yield.freeze
    end

    def get_i18n_cache(key)
      if class_variable_defined?(:"@@#{key}")
        class_variable_get(:"@@#{key}")
      else
        reset_i18n_cache(key)
      end
    end

    def reset_i18n_cache(key)
      class_variable_set(:"@@#{key}", {})
    end
  end
end

Version data entries

60 entries across 60 versions & 6 rubygems

Version Path
simple_form-3.5.0 lib/simple_form/i18n_cache.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simple_form-3.4.0/lib/simple_form/i18n_cache.rb
simple_form-3.4.0 lib/simple_form/i18n_cache.rb
simple_form-3.3.1 lib/simple_form/i18n_cache.rb
simple_form-3.3.0 lib/simple_form/i18n_cache.rb
simple_form-3.2.1 lib/simple_form/i18n_cache.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/simple_form-3.2.0/lib/simple_form/i18n_cache.rb
simple_form-3.2.0 lib/simple_form/i18n_cache.rb
simple_form-3.1.1 lib/simple_form/i18n_cache.rb
simple_form-3.0.4 lib/simple_form/i18n_cache.rb
simple_form-2.1.3 lib/simple_form/i18n_cache.rb
simple_form-2.1.2 lib/simple_form/i18n_cache.rb
simple_form-3.0.3 lib/simple_form/i18n_cache.rb
simple_form-3.1.0 lib/simple_form/i18n_cache.rb
simple_form-3.1.0.rc2 lib/simple_form/i18n_cache.rb
simple_form-3.1.0.rc1 lib/simple_form/i18n_cache.rb
simple_form-3.0.2 lib/simple_form/i18n_cache.rb
simple_form-3.0.1 lib/simple_form/i18n_cache.rb
simple_form-2.1.1 lib/simple_form/i18n_cache.rb
simple_form-3.0.0 lib/simple_form/i18n_cache.rb