Module: TranslationDiff::Configuration::CacheGuardOptions

Included in:
TranslationDiff::Configuration
Defined in:
lib/translation_diff/configuration/cache_guard_options.rb

Overview

Prepended onto Configuration: fails cache_prune_probability and cache_namespace at configure time, not later.

Constant Summary collapse

CACHE_NAMESPACE_LIMIT =
64

Instance Method Summary collapse

Instance Method Details

#cache_namespace=(value) ⇒ Object

Refused here, rather than at the first write's ActiveRecord::ValueTooLong.



13
14
15
16
17
18
# File 'lib/translation_diff/configuration/cache_guard_options.rb', line 13

def cache_namespace=(value)
  value = nil if value.is_a?(String) && value.strip.empty?
  raise namespace_too_long(value) if value.is_a?(String) && value.length > CACHE_NAMESPACE_LIMIT

  super
end

#cache_prune_probability=(value) ⇒ Object

An ENV var arrives as a String; coerced here so a translate call never meets a bare String's missing #positive?. Handed to super so the declared writer's cache_store invalidation still runs.



7
8
9
10
# File 'lib/translation_diff/configuration/cache_guard_options.rb', line 7

def cache_prune_probability=(value)
  value = nil if value.is_a?(String) && value.strip.empty?
  super(value.nil? ? nil : coerce_probability(value))
end