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
92 93 94 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 92 def acts_like_taggable? true end |
#tag_names ⇒ Object
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_string ⇒ Object
104 105 106 |
# File 'lib/acts_as_taggable/acts_as_taggable.rb', line 104 def tag_string tag_names.join([: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([: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.(tag_names).collect(&:name) end |