I18n::Backend::Cache

TODO Should the cache be cleared if new translations are stored?

Public Instance Methods

translate(locale, key, options = {}) click to toggle source
# File lib/i18n/backend/cache.rb, line 65
def translate(locale, key, options = {})
  I18n.perform_caching? ? fetch(cache_key(locale, key, options)) { super } : super
end

Protected Instance Methods

fetch(cache_key, &block) click to toggle source
# File lib/i18n/backend/cache.rb, line 71
def fetch(cache_key, &block)
  result = fetch_storing_missing_translation_exception(cache_key, &block)
  raise result if result.is_a?(Exception)
  result = result.dup if result.frozen? rescue result
  result
end
fetch_ignoring_procs(cache_key, &block) click to toggle source
# File lib/i18n/backend/cache.rb, line 85
def fetch_ignoring_procs(cache_key, &block)
  I18n.cache_store.read(cache_key) || yield.tap do |result|
    I18n.cache_store.write(cache_key, result) unless result.is_a?(Proc)
  end
fetch_storing_missing_translation_exception(cache_key, &block) click to toggle source
# File lib/i18n/backend/cache.rb, line 78
def fetch_storing_missing_translation_exception(cache_key, &block)
  fetch_ignoring_procs(cache_key, &block)
rescue MissingTranslationData => exception
  I18n.cache_store.write(cache_key, exception)
  exception
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.