Class: Tag
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Tag
- Includes:
- PagesCore::HumanizableParam
- Defined in:
- app/models/tag.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from PagesCore::HumanizableParam
Class Method Details
.parse(*tags) ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/models/tag.rb', line 21 def parse(*) Array().flatten .map { |tag| tag.is_a?(Tag) ? tag.name : tag } .map { |tag| tag.split(",") } .flatten .map(&:strip) end |
.tags_and_suggestions_for(taggable, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/models/tag.rb', line 12 def (taggable, = {}) limit = [:limit] || 100 = (taggable..sorted + pinned.sorted).uniq return unless .count < limit + suggestions(taggable, , limit)[0...(limit - .length)] end |
Instance Method Details
#==(other) ⇒ Object
63 64 65 |
# File 'app/models/tag.rb', line 63 def ==(other) super || name == other.to_s end |
#on(taggable) ⇒ Object
59 60 61 |
# File 'app/models/tag.rb', line 59 def on(taggable) taggings.create(taggable:) end |
#tagged ⇒ Object
55 56 57 |
# File 'app/models/tag.rb', line 55 def tagged @tagged ||= taggings.collect(&:taggable) end |
#to_param ⇒ Object
67 68 69 |
# File 'app/models/tag.rb', line 67 def to_param humanized_param(name) end |
#to_s ⇒ Object
71 72 73 |
# File 'app/models/tag.rb', line 71 def to_s name end |