Module: PagesCore::Taggable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Page
- Defined in:
- app/models/concerns/pages_core/taggable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#new_tags ⇒ Object
Returns the value of attribute new_tags.
Instance Method Summary collapse
- #serialized_tags ⇒ Object
- #serialized_tags=(json) ⇒ Object
- #tag_list ⇒ Object
- #tag_list=(tag_list) ⇒ Object
- #tag_names ⇒ Object
- #tag_with(*list) ⇒ Object
- #tag_with!(*list) ⇒ Object
Instance Attribute Details
#new_tags ⇒ Object
Returns the value of attribute new_tags.
7 8 9 |
# File 'app/models/concerns/pages_core/taggable.rb', line 7 def @new_tags end |
Instance Method Details
#serialized_tags ⇒ Object
26 27 28 |
# File 'app/models/concerns/pages_core/taggable.rb', line 26 def tag_names.to_json end |
#serialized_tags=(json) ⇒ Object
30 31 32 |
# File 'app/models/concerns/pages_core/taggable.rb', line 30 def (json) tag_with(ActiveSupport::JSON.decode(json)) end |
#tag_list ⇒ Object
46 47 48 |
# File 'app/models/concerns/pages_core/taggable.rb', line 46 def tag_list tag_names.join(", ") end |
#tag_list=(tag_list) ⇒ Object
42 43 44 |
# File 'app/models/concerns/pages_core/taggable.rb', line 42 def tag_list=(tag_list) tag_with(tag_list) end |
#tag_names ⇒ Object
50 51 52 |
# File 'app/models/concerns/pages_core/taggable.rb', line 50 def tag_names @new_tags || .by_name.map(&:name) end |
#tag_with(*list) ⇒ Object
34 35 36 |
# File 'app/models/concerns/pages_core/taggable.rb', line 34 def tag_with(*list) @new_tags = Tag.parse(list) end |
#tag_with!(*list) ⇒ Object
38 39 40 |
# File 'app/models/concerns/pages_core/taggable.rb', line 38 def tag_with!(*list) update(tag_list: list) end |