class Card::Rule::PreferenceCache
a preference is a user-specific rule. This caches all preferences in the deck
Constants
- USER_ID_CACHE_KEY
Public Class Methods
Source
# File lib/card/rule/preference_cache.rb, line 57 def clear super Card.cache.write USER_ID_CACHE_KEY, nil end
Calls superclass method
Card::Rule::Cache::clear
Source
# File lib/card/rule/preference_cache.rb, line 68 def lookup_key row return unless (base = lookup_key_without_user row) "#{base}+#{row['user_id']}" end
Also aliased as: lookup_key_without_user
Source
# File lib/card/rule/preference_cache.rb, line 37 def populate @rows = nil super.tap do populate_user_ids @rows = nil end end
Calls superclass method
Card::Rule::Cache::populate
Source
# File lib/card/rule/preference_cache.rb, line 45 def populate_user_ids Card.cache.write USER_ID_CACHE_KEY, user_id_hash end
Source
# File lib/card/rule/preference_cache.rb, line 62 def rows @rows ||= super end
Calls superclass method
Card::Rule::Cache::rows
Source
# File lib/card/rule/preference_cache.rb, line 49 def user_id_hash rows.each_with_object({}) do |row, hash| key = lookup_key_without_user row hash[key] ||= [] hash[key] << row["user_id"] end end
Source
# File lib/card/rule/preference_cache.rb, line 33 def user_ids Card.cache.read(USER_ID_CACHE_KEY) || (populate && user_ids) end