Class: NiceCache::Tag
- Inherits:
-
Object
- Object
- NiceCache::Tag
- Defined in:
- lib/nice_cache/tag.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attach_on(fragment) ⇒ Object
- #fragments ⇒ Object
-
#initialize(nice_cache, name) ⇒ Tag
constructor
A new instance of Tag.
- #remove_from(fragment) ⇒ Object
- #sweep ⇒ Object
Constructor Details
#initialize(nice_cache, name) ⇒ Tag
Returns a new instance of Tag.
9 10 11 12 |
# File 'lib/nice_cache/tag.rb', line 9 def initialize(nice_cache, name) @nice_cache = nice_cache @name = name.to_s end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/nice_cache/tag.rb', line 3 def name @name end |
Class Method Details
.find(nice_cache, *tag_names) ⇒ Object
5 6 7 |
# File 'lib/nice_cache/tag.rb', line 5 def self.find(nice_cache, *tag_names) tag_names.flatten.map{ |tag_symbol| new(nice_cache, tag_symbol) } end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 37 |
# File 'lib/nice_cache/tag.rb', line 33 def ==(other) name == other.name rescue false end |
#attach_on(fragment) ⇒ Object
14 15 16 17 18 |
# File 'lib/nice_cache/tag.rb', line 14 def attach_on(fragment) save_fragment(fragment.name) fragment.attach_with(self) self end |
#fragments ⇒ Object
20 21 22 |
# File 'lib/nice_cache/tag.rb', line 20 def fragments fragments_list.map{ |fragment_name| Fragment.find(@nice_cache, fragment_name) } end |
#remove_from(fragment) ⇒ Object
24 25 26 |
# File 'lib/nice_cache/tag.rb', line 24 def remove_from(fragment) store.srem(tag_key, fragment.name) end |
#sweep ⇒ Object
28 29 30 31 |
# File 'lib/nice_cache/tag.rb', line 28 def sweep fragments.map(&:delete) destroy end |