Class: CanTango::Ability::Cache::Writer
- Inherits:
-
Object
- Object
- CanTango::Ability::Cache::Writer
- Includes:
- Helpers::Debug
- Defined in:
- lib/cantango/ability/cache/writer.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#cache_key ⇒ Object
readonly
Returns the value of attribute cache_key.
Instance Method Summary collapse
-
#initialize(cache) ⇒ Writer
constructor
A new instance of Writer.
- #save(key, rules) ⇒ Object
Methods included from Helpers::Debug
Constructor Details
#initialize(cache) ⇒ Writer
Returns a new instance of Writer.
11 12 13 |
# File 'lib/cantango/ability/cache/writer.rb', line 11 def initialize cache @cache = cache end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
7 8 9 |
# File 'lib/cantango/ability/cache/writer.rb', line 7 def cache @cache end |
#cache_key ⇒ Object (readonly)
Returns the value of attribute cache_key.
7 8 9 |
# File 'lib/cantango/ability/cache/writer.rb', line 7 def cache_key @cache_key end |
Instance Method Details
#save(key, rules) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/cantango/ability/cache/writer.rb', line 15 def save key, rules cache.invalidate! return if prepared_rules.blank? debug "writing #{prepared_rules.size} rules to cache: #{key}" cache.rules_cache.save cache.key, prepared_rules session[cache_key] = cache.key if session end |