Class: RestrictCache::Cacheable

Inherits:
Object
  • Object
show all
Defined in:
lib/restrict_cache/cacheable.rb,
lib/restrict_cache/cacheable/base.rb,
lib/restrict_cache/cacheable/custom_cache.rb,
lib/restrict_cache/cacheable/active_record_cache.rb

Defined Under Namespace

Modules: CacheKey Classes: ActiveRecordCache, Base, CustomCache

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCacheable

Returns a new instance of Cacheable.



34
35
36
# File 'lib/restrict_cache/cacheable.rb', line 34

def initialize
  @cache_collection = {}
end

Class Method Details

.build_inner_cache(key) ⇒ Object



23
24
25
# File 'lib/restrict_cache/cacheable.rb', line 23

def build_inner_cache(key)
  const_get(key.to_s.classify, false).new
end

Instance Method Details

#[](key) ⇒ Object



42
43
44
45
# File 'lib/restrict_cache/cacheable.rb', line 42

def [](key)
  return nil unless key
  @cache_collection[key]
end

#add(content) ⇒ Object



38
39
40
# File 'lib/restrict_cache/cacheable.rb', line 38

def add(content)
  inner_cache(CacheKey.get(content)).add(content)
end

#cache_keysObject



47
48
49
# File 'lib/restrict_cache/cacheable.rb', line 47

def cache_keys
  CacheKey::ALL
end