Class: Friendly::Cache
- Defined in:
- lib/friendly/cache.rb,
lib/friendly/cache/by_id.rb
Direct Known Subclasses
Defined Under Namespace
Classes: ByID
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(klass, fields, options = {}, cache = Friendly.cache) ⇒ Cache
constructor
A new instance of Cache.
Methods inherited from Storage
#all, #count, #create, #destroy, #first, #satisfies?, #update
Constructor Details
#initialize(klass, fields, options = {}, cache = Friendly.cache) ⇒ Cache
Returns a new instance of Cache.
17 18 19 20 21 22 |
# File 'lib/friendly/cache.rb', line 17 def initialize(klass, fields, = {}, cache = Friendly.cache) @klass = klass @fields = fields @cache = cache @version = [:version] || 0 end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
15 16 17 |
# File 'lib/friendly/cache.rb', line 15 def cache @cache end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
15 16 17 |
# File 'lib/friendly/cache.rb', line 15 def fields @fields end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
15 16 17 |
# File 'lib/friendly/cache.rb', line 15 def klass @klass end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
15 16 17 |
# File 'lib/friendly/cache.rb', line 15 def version @version end |
Class Method Details
.cache_for(klass, fields, options) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/friendly/cache.rb', line 6 def cache_for(klass, fields, ) unless fields == [:id] raise NotSupported, "Caching is only possible by id at the moment." end ByID.new(klass, fields, ) end |