module Card::Cache::Prepopulate

pre-populate cache for testing purposes

Public Instance Methods

restore() click to toggle source
# File lib/card/cache/prepopulate.rb, line 5
def restore
  reset_soft
  prepopulate
end

Private Instance Methods

prepopulate() click to toggle source
# File lib/card/cache/prepopulate.rb, line 16
def prepopulate
  return unless prepopulate?

  prepopulate_rule_caches
  # prepopulate_lexicon_caches
end
prepopulate?() click to toggle source
# File lib/card/cache/prepopulate.rb, line 12
def prepopulate?
  Cardio.config.prepopulate_cache
end
prepopulate_cache(variable) { || ... } click to toggle source
# File lib/card/cache/prepopulate.rb, line 23
def prepopulate_cache variable
  @prepopulated ||= {}
  value = @prepopulated[variable] ||= yield
  Card.cache.soft.write variable, value.clone
end
prepopulate_rule_caches() click to toggle source

def prepopulate_lexicon_caches end

# File lib/card/cache/prepopulate.rb, line 32
def prepopulate_rule_caches
  prepopulate_cache("RULES") { Card::Rule.rule_cache }
  prepopulate_cache("READRULES") { Card::Rule.read_rule_cache }
  prepopulate_cache("PREFERENCES") { Card::Rule.preference_cache }
end