Module: Mongoid::TagCollectible::Tagged::ClassMethods
- Defined in:
- lib/mongoid-tag-collectible/tagged.rb
Instance Method Summary collapse
Instance Method Details
#remove_tag!(tag_name) ⇒ Object
33 34 35 |
# File 'lib/mongoid-tag-collectible/tagged.rb', line 33 def remove_tag!(tag_name) collection.where(tags: tag_name).update({ '$pull' => { tags: tag_name } }, multi: true) end |
#rename_tag!(old_tag, new_tag) ⇒ Object
28 29 30 31 |
# File 'lib/mongoid-tag-collectible/tagged.rb', line 28 def rename_tag!(old_tag, new_tag) collection.where(tags: old_tag).update({ '$addToSet' => { tags: new_tag } }, multi: true) self.remove_tag!(old_tag) end |