Class: Taggable

Inherits:
ApplicationRecord show all
Defined in:
lib/needle_in_a_haystack/concerns/taggable.rb

Overview

This model represents an entity that can be tagged with HaystackTags through HaystackTaggings.

Instance Method Summary collapse

Instance Method Details

#add_haystack_marker(marker) ⇒ Object



6
7
8
9
10
# File 'lib/needle_in_a_haystack/concerns/taggable.rb', line 6

def add_haystack_marker(marker)
  self.tags ||= {}
  self.tags[marker] = true
  save!
end

#add_haystack_tag(key, value) ⇒ Object



12
13
14
15
16
# File 'lib/needle_in_a_haystack/concerns/taggable.rb', line 12

def add_haystack_tag(key, value)
  self.tags ||= {}
  self.tags[key] = value
  save!
end

#add_multiple_tags(tags_hash) ⇒ Object



18
19
20
21
22
# File 'lib/needle_in_a_haystack/concerns/taggable.rb', line 18

def add_multiple_tags(tags_hash)
  self.tags ||= {}
  self.tags.merge!(tags_hash)
  save!
end