Class: CanTango::Ability::Cache::SessionCache
- Defined in:
- lib/cantango/ability/cache/session_cache.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
Returns the value of attribute session.
Attributes inherited from BaseCache
Instance Method Summary collapse
- #cache ⇒ Object
-
#initialize(name, options = {}) ⇒ SessionCache
constructor
will be called with :session => session (pointing to user session).
- #invalidate!(key) ⇒ Object
- #load(key) ⇒ Object
- #save(key, rules) ⇒ Object
- #store ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ SessionCache
will be called with :session => session (pointing to user session)
8 9 10 11 12 13 14 |
# File 'lib/cantango/ability/cache/session_cache.rb', line 8 def initialize name, = {} super # will set all instance vars using options hash @cache = cache @cache.configure_with :type => :memory raise "SessionCache must be initialized with a :session option" if !session session[:rules_cache] = @cache end |
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
5 6 7 |
# File 'lib/cantango/ability/cache/session_cache.rb', line 5 def session @session end |
Instance Method Details
#cache ⇒ Object
32 33 34 35 |
# File 'lib/cantango/ability/cache/session_cache.rb', line 32 def cache CanTango::Cache::HashCache.instance # CanTango::Cache::MonetaCache.instance end |
#invalidate!(key) ⇒ Object
28 29 30 |
# File 'lib/cantango/ability/cache/session_cache.rb', line 28 def invalidate! key store.delete key end |
#load(key) ⇒ Object
20 21 22 |
# File 'lib/cantango/ability/cache/session_cache.rb', line 20 def load key store.load! key end |
#save(key, rules) ⇒ Object
24 25 26 |
# File 'lib/cantango/ability/cache/session_cache.rb', line 24 def save key, rules store.save! key, rules end |
#store ⇒ Object
16 17 18 |
# File 'lib/cantango/ability/cache/session_cache.rb', line 16 def store session[:rules_cache] end |