Sha256: 59ed15f65b5a44a0bbf30f540957525da4de8ff516d5946ce9553a7eb9aa1abf
Contents?: true
Size: 597 Bytes
Versions: 8
Compression:
Stored size: 597 Bytes
Contents
# frozen_string_literal: true 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
8 entries across 8 versions & 1 rubygems