class RestrictCache::CacheCollection::ActiveRecordCache

Public Instance Methods

add(content) click to toggle source
# File lib/restrict_cache/cache_collection/active_record_cache.rb, line 4
def add(content)
  tbl_name, index = table_name_of(content), index_of(content)
  @caches[tbl_name] ||= {}
  @caches[tbl_name][index] = content
end
contents(_table_name) click to toggle source
# File lib/restrict_cache/cache_collection/active_record_cache.rb, line 10
def contents(_table_name)
  @caches[_table_name.to_sym]
end

Private Instance Methods

index_of(content) click to toggle source
# File lib/restrict_cache/cache_collection/active_record_cache.rb, line 19
def index_of(content)
  content.public_send content.class.primary_key
end
table_name_of(content) click to toggle source
# File lib/restrict_cache/cache_collection/active_record_cache.rb, line 15
def table_name_of(content)
  content.class.table_name.to_sym
end