Class: Catche::Tag::Collect
- Inherits:
-
Object
- Object
- Catche::Tag::Collect
- Defined in:
- lib/catche/tag/collect.rb
Class Method Summary collapse
-
.collection(context, resource_class = nil, include_base = true) ⇒ Object
Collects collection tags for a given context, for example the resource or a controller.
-
.resource(resource) ⇒ Object
Collects resource tags for a given resource.
Class Method Details
.collection(context, resource_class = nil, include_base = true) ⇒ Object
Collects collection tags for a given context, for example the resource or a controller
Catche::Tag::Collect.collection(@task)
=> { :set => ["projects_1_tasks"], :expire => ["tasks", "projects_1_tasks"] }
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/catche/tag/collect.rb', line 28 def collection(context, resource_class=nil, include_base=true) resource_class ||= context.class associations = Catche::ResourceLoader.fetch(context, *resource_class.catche_associations) = associations.map { |a| a.catche_tag } = [] = [] .each do |tag| << Tag.join(tag, resource_class.catche_tag) end << resource_class.catche_tag if .blank? << resource_class.catche_tag if include_base += { :set => .uniq, :expire => .uniq } end |
.resource(resource) ⇒ Object
Collects resource tags for a given resource
Catche::Tag::Collect.resource_tags(@task)
=> { :set => ["tasks_1"], :expire => ["tasks_1"] }
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/catche/tag/collect.rb', line 11 def resource(resource) = [] = [] << resource.catche_tag << resource.catche_tag { :set => .uniq, :expire => .uniq } end |