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

Instance Method Summary collapse

Instance Attribute Details

#new_tagsObject

Returns the value of attribute new_tags.



7
8
9
# File 'app/models/concerns/pages_core/taggable.rb', line 7

def new_tags
  @new_tags
end

Instance Method Details

#serialized_tagsObject



26
27
28
# File 'app/models/concerns/pages_core/taggable.rb', line 26

def serialized_tags
  tag_names.to_json
end

#serialized_tags=(json) ⇒ Object



30
31
32
# File 'app/models/concerns/pages_core/taggable.rb', line 30

def serialized_tags=(json)
  tag_with(ActiveSupport::JSON.decode(json))
end

#tag_listObject



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_namesObject



50
51
52
# File 'app/models/concerns/pages_core/taggable.rb', line 50

def tag_names
  @new_tags || 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