module ActsAsTaggableOnMongoid::Models::Concerns::TagMethods

Public Instance Methods

==(other) click to toggle source

INSTANCE METHODS:

Calls superclass method
# File lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb, line 62
def ==(other)
  super || (other.class == self.class &&
      name == other.name &&
      context == other.context &&
      taggable_type == other.taggable_type)
end
as_8bit_ascii(string) click to toggle source
# File lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb, line 45
def as_8bit_ascii(string)
  string = string.to_s

  string.mb_chars
end
create_tag(tag_definition, owner, name) click to toggle source

:reek: UtilityFunction

# File lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb, line 38
def create_tag(tag_definition, owner, name)
  tag_definition.tags_table.create!(name:          name,
                                    owner:         owner,
                                    context:       tag_definition.tag_type,
                                    taggable_type: tag_definition.owner.name)
end
find_or_create_all_with_like_by_name_owner(tag_definition, owner, *list) click to toggle source
# File lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb, line 19
def find_or_create_all_with_like_by_name_owner(tag_definition, owner, *list)
  list = ActsAsTaggableOnMongoid::TagList.new(tag_definition, *Array.wrap(list).flatten)

  return [] if list.empty?

  list.map do |tag_name|
    tries ||= 3

    find_or_create_tag(tag_name, tag_definition, owner)
  rescue StandardError
    if (tries -= 1).positive?
      retry
    end

    raise
  end
end
find_or_create_tag(tag_name, tag_definition, owner) click to toggle source
# File lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb, line 51
def find_or_create_tag(tag_name, tag_definition, owner)
  existing_tag = tag_definition.tags_table.for_tag(tag_definition).named(tag_name).owned_by(owner).first

  existing_tag || create_tag(tag_definition, owner, tag_name)
end
find_or_create_tagger_list_with_like_by_name(tag_definition, tagger_list) click to toggle source
# File lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb, line 13
def find_or_create_tagger_list_with_like_by_name(tag_definition, tagger_list)
  tagger_list.each_with_object([]) do |(tagger, tag_list), array|
    array.concat find_or_create_all_with_like_by_name_owner tag_definition, tagger, tag_list
  end
end
to_s() click to toggle source
# File lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb, line 69
def to_s
  name
end

Private Instance Methods

tag_definition() click to toggle source
# File lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb, line 75
def tag_definition
  @tag_definition ||= taggable_type.constantize.tag_types[context]
end