Module: Motor::Tags
- Defined in:
- lib/motor/tags.rb
Class Method Summary collapse
Class Method Details
.assign_tags(taggable, tags) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/motor/tags.rb', line 7 def (taggable, ) return taggable unless .each do |tag_name| next if taggable..find { |tt| tt.tag.name.casecmp(tag_name).zero? } tag = Tag.find_or_initialize_by(name: tag_name) taggable..new(tag: tag) end (taggable, ) if taggable.persisted? taggable end |
.remove_missing_tags(taggable, tags) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/motor/tags.rb', line 23 def (taggable, ) = .map(&:downcase) = taggable..reject { |tt| tt.name.downcase.in?() } taggable. -= taggable end |