Class: Spree::Preferences::StoreInstance
- Inherits:
-
Object
- Object
- Spree::Preferences::StoreInstance
- Defined in:
- app/models/spree/preferences/store.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#persistence ⇒ Object
Returns the value of attribute persistence.
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #exist?(key) ⇒ Boolean
- #get(key) ⇒ Object
-
#initialize ⇒ StoreInstance
constructor
A new instance of StoreInstance.
- #set(key, value, type) ⇒ Object
Constructor Details
#initialize ⇒ StoreInstance
Returns a new instance of StoreInstance.
14 15 16 17 18 |
# File 'app/models/spree/preferences/store.rb', line 14 def initialize @cache = Rails.cache @persistence = true load_preferences end |
Instance Attribute Details
#persistence ⇒ Object
Returns the value of attribute persistence.
12 13 14 |
# File 'app/models/spree/preferences/store.rb', line 12 def persistence @persistence end |
Instance Method Details
#delete(key) ⇒ Object
33 34 35 36 |
# File 'app/models/spree/preferences/store.rb', line 33 def delete(key) @cache.delete(key) destroy(key) end |
#exist?(key) ⇒ Boolean
25 26 27 |
# File 'app/models/spree/preferences/store.rb', line 25 def exist?(key) @cache.exist? key end |
#get(key) ⇒ Object
29 30 31 |
# File 'app/models/spree/preferences/store.rb', line 29 def get(key) @cache.read(key) end |
#set(key, value, type) ⇒ Object
20 21 22 23 |
# File 'app/models/spree/preferences/store.rb', line 20 def set(key, value, type) @cache.write(key, value) persist(key, value, type) end |