Module: EasyTag::Taggable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/easy_tag/taggable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #is_taggable? ⇒ Boolean
-
#set_tags(tag_list, options = {}) ⇒ Object
end of class methods.
- #tags=(tag_list) ⇒ Object
Instance Method Details
#is_taggable? ⇒ Boolean
99 100 101 |
# File 'lib/easy_tag/taggable.rb', line 99 def is_taggable? return true end |
#set_tags(tag_list, options = {}) ⇒ Object
end of class methods
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/easy_tag/taggable.rb', line 67 def (tag_list, = {}) .reverse_merge! :context => nil, :tagger => nil, :downcase => true, :delimiter => ',' if block_given? = yield(klass) else = EasyTag::Tag.compact_tag_list(tag_list, .slice(:downcase, :delimiter)) end context = compact_context([:context]) tagger = compact_tagger([:tagger]) # Remove old tags self.taggings.where(:tag_context_id => context.try(:id), :tagger_id => tagger.try(:id)).destroy_all # TODO: should remove unused tags and contexts if .each do |t| tag = EasyTag::Tag.where(:name => t).first_or_create raise SimgleTag::InvalidTag if tag.nil? self.taggings.where(:tagger_id => tagger.try(:id), :tag_context_id => context.try(:id), :tag_id => tag.id).first_or_create end end end |
#tags=(tag_list) ⇒ Object
95 96 97 |
# File 'lib/easy_tag/taggable.rb', line 95 def (tag_list) self.(tag_list) end |