Module: PermaCache
- Defined in:
- lib/perma_cache.rb,
lib/perma_cache/version.rb
Defined Under Namespace
Modules: ClassMethods
Classes: UndefinedCache
Constant Summary
collapse
- VERSION =
"0.3.0"
Class Method Summary
collapse
Class Method Details
.build_key_from_object(obj) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/perma_cache.rb', line 28
def self.build_key_from_object(obj)
Array.new.tap do |arr|
if obj.respond_to?(:cache_key)
arr << obj.cache_key
else
arr << (obj.is_a?(Module) ? obj.name : obj.class.name)
if obj.respond_to?(:id)
arr << obj.id
end
end
end
end
|
.cache ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/perma_cache.rb', line 20
def self.cache
if defined?(@cache) && @cache.is_a?(Symbol)
@cache = @cache.to_s.classify.constantize
else
@cache ||= raise(UndefinedCache, "Please define a cache object: (PermaCache.cache = Rails.cache)")
end
end
|
.cache=(c) ⇒ Object
16
17
18
|
# File 'lib/perma_cache.rb', line 16
def self.cache=(c)
@cache = c
end
|
.included(base) ⇒ Object
43
44
45
|
# File 'lib/perma_cache.rb', line 43
def self.included(base)
base.extend ClassMethods
end
|
.version ⇒ Object
12
13
14
|
# File 'lib/perma_cache.rb', line 12
def self.version
@version ||= 1
end
|
.version=(v) ⇒ Object
8
9
10
|
# File 'lib/perma_cache.rb', line 8
def self.version=(v)
@version = v
end
|