Class: Snaps::Tag
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Snaps::Tag
- Includes:
- Suppressor
- Defined in:
- app/models/snaps/tag.rb
Class Method Summary collapse
- .all_revisions_with_tag(model, tag) ⇒ Object
- .current_revisions_with_tag(model, tag) ⇒ Object
- .for_all_revisions_of(record) ⇒ Object
- .supersede! ⇒ Object
Methods included from Suppressor
Class Method Details
.all_revisions_with_tag(model, tag) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/models/snaps/tag.rb', line 32 def self.all_revisions_with_tag(model, tag) model.joins(" INNER JOIN snaps_tags\n ON \#{model.table_name}.id = snaps_tags.record_id\n AND snaps_tags.record_type = '\#{model.name}'\n AND snaps_tags.tag = '\#{tag}'\n SQL\nend\n") |
.current_revisions_with_tag(model, tag) ⇒ Object
41 42 43 |
# File 'app/models/snaps/tag.rb', line 41 def self.current_revisions_with_tag(model, tag) all_revisions_with_tag(model, tag).where('snaps_tags.superseded_at IS NULL') end |
.for_all_revisions_of(record) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/models/snaps/tag.rb', line 23 def self.for_all_revisions_of(record) joins(" INNER JOIN \#{record.class.table_name}\n ON \#{record.class.table_name}.id = snaps_tags.record_id\n AND snaps_tags.record_type = '\#{record.class.name}'\n AND perma_id = \#{record.perma_id}\n SQL\nend\n") |
.supersede! ⇒ Object
19 20 21 |
# File 'app/models/snaps/tag.rb', line 19 def self.supersede! current.update_all(superseded_at: Time.now) end |