module SimpleForm::I18nCache
A lot of configuration values are retrived from I18n, like boolean collection, required string. This module provides caching facility to speed up form construction.
Public Instance Methods
get_i18n_cache(key)
click to toggle source
# File lib/simple_form/i18n_cache.rb, line 11 def get_i18n_cache(key) if class_variable_defined?(:"@@#{key}") class_variable_get(:"@@#{key}") else reset_i18n_cache(key) end end
i18n_cache(key) { || ... }
click to toggle source
# File lib/simple_form/i18n_cache.rb, line 7 def i18n_cache(key) get_i18n_cache(key)[I18n.locale] ||= yield.freeze end
reset_i18n_cache(key)
click to toggle source
# File lib/simple_form/i18n_cache.rb, line 19 def reset_i18n_cache(key) class_variable_set(:"@@#{key}", {}) end