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
22 23 24 25 26 27 28 |
# File 'app/models/tag.rb', line 22 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
13 14 15 16 17 18 19 20 |
# File 'app/models/tag.rb', line 13 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
64 65 66 |
# File 'app/models/tag.rb', line 64 def ==(other) super || name == other.to_s end |
#on(taggable) ⇒ Object
60 61 62 |
# File 'app/models/tag.rb', line 60 def on(taggable) taggings.create(taggable:) end |
#tagged ⇒ Object
56 57 58 |
# File 'app/models/tag.rb', line 56 def tagged @tagged ||= taggings.collect(&:taggable) end |
#to_param ⇒ Object
68 69 70 |
# File 'app/models/tag.rb', line 68 def to_param humanized_param(name) end |
#to_s ⇒ Object
72 73 74 |
# File 'app/models/tag.rb', line 72 def to_s name end |