Module: ActsAsTaggable::InstanceMethods
- Defined in:
- lib/acts_as_taggable/acts_as_taggable.rb
Instance Method Summary collapse
- #acts_like_taggable? ⇒ Boolean
- #tag_names ⇒ Object
- #tag_names=(names) ⇒ Object
- #tag_string ⇒ Object
- #tag_string=(tag_string) ⇒ Object
- #tag_with(*tag_names) ⇒ Object
- #untag_with(*tag_names) ⇒ Object
Instance Method Details
#acts_like_taggable? ⇒ Boolean
99 100 101 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 99 def acts_like_taggable? true end |
#tag_names ⇒ Object
119 120 121 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 119 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
123 124 125 126 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 123 def tag_names=(names) tag_objects = names.select(&:present?).collect {|tag_name| self.class.create_tag(tag_name) }.uniq send HelperMethods.scoped_association_assignment_name, tag_objects end |
#tag_string ⇒ Object
111 112 113 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 111 def tag_string tag_names.join([:output_delimiter] + ' ') end |
#tag_string=(tag_string) ⇒ Object
115 116 117 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 115 def tag_string=(tag_string) self.tag_names = tag_string.to_s.split([:delimiter]) end |
#tag_with(*tag_names) ⇒ Object
103 104 105 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 103 def tag_with(*tag_names) self.tag_names |= tag_names.flatten end |
#untag_with(*tag_names) ⇒ Object
107 108 109 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 107 def untag_with(*tag_names) self.tag_names = self.tag_names - self.class.(tag_names).collect(&:name) end |