Module: ActsAsTaggable::InstanceMethods

Defined in:
lib/acts_as_taggable/acts_as_taggable.rb

Instance Method Summary collapse

Instance Method Details

#acts_like_taggable?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 92

def acts_like_taggable?
  true
end

#tag_namesObject



112
113
114
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 112

def tag_names
  send(HelperMethods.scoped_association_name).collect(&:name) # don't use pluck since we want to use the cached association
end

#tag_names=(names) ⇒ Object



116
117
118
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 116

def tag_names=(names)
  send HelperMethods.scoped_association_assignment_name, names.select(&:present?).collect {|tag_name| self.class.create_tag(tag_name) }
end

#tag_stringObject



104
105
106
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 104

def tag_string
  tag_names.join(acts_as_taggable_options[:output_delimiter] + ' ')
end

#tag_string=(tag_string) ⇒ Object



108
109
110
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 108

def tag_string=(tag_string)
  self.tag_names = tag_string.to_s.split(acts_as_taggable_options[:delimiter])
end

#tag_with(*tag_names) ⇒ Object



96
97
98
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 96

def tag_with(*tag_names)
  self.tag_names = tag_names.flatten
end

#untag_with(*tag_names) ⇒ Object



100
101
102
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 100

def untag_with(*tag_names)
  self.tag_names = self.tag_names - self.class.find_tags(tag_names).collect(&:name)
end