Class: Rack::Cache::Tags::Store::ActiveRecord
- Inherits:
-
Object
- Object
- Rack::Cache::Tags::Store::ActiveRecord
- Defined in:
- lib/rack/cache/tags/store/active_record.rb
Defined Under Namespace
Classes: Tagging
Instance Method Summary collapse
- #purge(tags) ⇒ Object
- #store(url, tags) ⇒ Object
- #taggings_by_tags(tags) ⇒ Object
- #urls_by_tags(tags) ⇒ Object
Instance Method Details
#purge(tags) ⇒ Object
16 17 18 |
# File 'lib/rack/cache/tags/store/active_record.rb', line 16 def purge() ().tap { |urls| Tagging.where(:url => urls).delete_all } end |
#store(url, tags) ⇒ Object
12 13 14 |
# File 'lib/rack/cache/tags/store/active_record.rb', line 12 def store(url, ) .each { |tag| Tagging.find_or_create_by_url_and_tag(url, tag) } end |
#taggings_by_tags(tags) ⇒ Object
24 25 26 27 |
# File 'lib/rack/cache/tags/store/active_record.rb', line 24 def () sql = "tag IN (?) #{[' OR tag LIKE ?'] * .size}" Tagging.where(sql, , *.map { |tag| "#{tag.split(':').first}%" }) end |
#urls_by_tags(tags) ⇒ Object
20 21 22 |
# File 'lib/rack/cache/tags/store/active_record.rb', line 20 def () ().map(&:url) end |