module ActsAsTaggableOnMongoid::Models::Concerns::TaggingMethods

This module includes the methods and callbacks needed/used by a Tagging model

Private Instance Methods

remove_unused_tags() click to toggle source

INSTANCE METHODS:

# File lib/acts_as_taggable_on_mongoid/models/concerns/tagging_methods.rb, line 20
def remove_unused_tags
  return nil unless taggable

  tag_definition = taggable.tag_types[context]

  return unless tag_definition&.remove_unused_tags?

  tag.destroy if tag.reload.taggings_count.zero?
end
tagging_destroyed() click to toggle source
# File lib/acts_as_taggable_on_mongoid/models/concerns/tagging_methods.rb, line 39
def tagging_destroyed
  taggable_was = taggable_type_was.constantize.where(id: taggable_id_was).first

  return unless taggable_was

  tag_definition = taggable_was.tag_types[context_was]

  return unless tag_definition

  taggable_was.public_send(tag_definition.tagger_tag_lists_name)[tagger].remove(tag_name_was)
end
tagging_saved() click to toggle source
# File lib/acts_as_taggable_on_mongoid/models/concerns/tagging_methods.rb, line 30
def tagging_saved
  tag_definition = taggable.tag_types[context]

  return unless tag_definition

  tag_list = taggable.public_send(tag_definition.tagger_tag_lists_name)[tagger]
  tag_list.add_tagging(self)
end