Module: Taggable::Model::TaggableInstanceMethods
- Defined in:
- lib/taggable/model.rb
Instance Method Summary collapse
- #add_tag(word = nil) ⇒ Object
- #closely_related ⇒ Object
- #keywords ⇒ Object
- #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
122 123 124 |
# File 'lib/taggable/model.rb', line 122 def keywords self..map {|t| t.title}.join(', ') end |
#keywords=(somewords = "") ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/taggable/model.rb', line 126 def keywords=(somewords="") if somewords.blank? self..clear else self. = Tag.from_list(somewords) end end |
#keywords_before_type_cast ⇒ Object
for form_helper
134 135 136 |
# File 'lib/taggable/model.rb', line 134 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 |