Module: Taggable::Model::TaggableInstanceMethods
- Defined in:
- lib/taggable/model.rb
Instance Method Summary collapse
- #add_tag(word = nil) ⇒ Object
- #closely_related ⇒ Object
-
#keywords ⇒ Object
in the case of pages and anything else that keywords in the same way this overrides the existing column the rest of the time it’s just another way of specifying tags.
- #keywords=(somewords = "") ⇒ Object
-
#keywords_before_type_cast ⇒ Object
for form_helper.
- #related ⇒ Object
- #remove_tag(word = nil) ⇒ Object
- #tags_from_keywords ⇒ Object
Instance Method Details
#add_tag(word = nil) ⇒ Object
105 106 107 |
# File 'lib/taggable/model.rb', line 105 def add_tag(word=nil) self. << Tag.for(word) if word && !word.blank? end |
#closely_related ⇒ Object
118 119 120 |
# File 'lib/taggable/model.rb', line 118 def self..empty? ? [] : self.class.(self.) - [self] end |
#keywords ⇒ Object
in the case of pages and anything else that keywords in the same way this overrides the existing column the rest of the time it’s just another way of specifying tags.
125 126 127 |
# File 'lib/taggable/model.rb', line 125 def keywords self..map {|t| t.title}.join(', ') end |
#keywords=(somewords = "") ⇒ Object
129 130 131 132 133 134 135 |
# File 'lib/taggable/model.rb', line 129 def keywords=(somewords="") if somewords.blank? self..clear else self. = Tag.from_list(somewords) end end |
#keywords_before_type_cast ⇒ Object
for form_helper
137 138 139 |
# File 'lib/taggable/model.rb', line 137 def keywords_before_type_cast # for form_helper keywords end |
#related ⇒ Object
114 115 116 |
# File 'lib/taggable/model.rb', line 114 def self..empty? ? [] : self.class.(self.) - [self] end |
#remove_tag(word = nil) ⇒ Object
109 110 111 112 |
# File 'lib/taggable/model.rb', line 109 def remove_tag(word=nil) tag = Tag.find_by_title(word) if word && !word.blank? self..delete(tag) if tag end |