Class: NiceCache::Fragment
- Inherits:
-
Object
- Object
- NiceCache::Fragment
- Defined in:
- lib/nice_cache/fragment.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_with(tag) ⇒ Object
- #delete ⇒ Object
-
#initialize(nice_cache, name, tag_names = []) ⇒ Fragment
constructor
A new instance of Fragment.
- #tags ⇒ Object
Constructor Details
#initialize(nice_cache, name, tag_names = []) ⇒ Fragment
Returns a new instance of Fragment.
13 14 15 16 17 18 19 20 |
# File 'lib/nice_cache/fragment.rb', line 13 def initialize(nice_cache, name, tag_names = []) @nice_cache = nice_cache @name = name unless tag_names.empty? (tag_names) persist end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/nice_cache/fragment.rb', line 3 def name @name end |
Class Method Details
.all ⇒ Object
5 6 7 |
# File 'lib/nice_cache/fragment.rb', line 5 def self.all "AllFragments" end |
.find(nice_cache, name) ⇒ Object
9 10 11 |
# File 'lib/nice_cache/fragment.rb', line 9 def self.find(nice_cache, name) new(nice_cache, name) end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 42 43 |
# File 'lib/nice_cache/fragment.rb', line 39 def ==(other) name == other.name rescue false end |
#attach_with(tag) ⇒ Object
26 27 28 |
# File 'lib/nice_cache/fragment.rb', line 26 def attach_with(tag) store.sadd(, tag.name) end |
#delete ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/nice_cache/fragment.rb', line 30 def delete .each do |tag| tag.remove_from(self) end # TODO: Timestamps destroy end |
#tags ⇒ Object
22 23 24 |
# File 'lib/nice_cache/fragment.rb', line 22 def Tag.find(@nice_cache, ) end |