Sha256: bfd4bc62c4783d83518cba8cb8cbbac9c866f231d0a50b897435199a9f45d603

Contents?: true

Size: 466 Bytes

Versions: 3

Compression:

Stored size: 466 Bytes

Contents

class Taggable < ApplicationRecord
  has_many :haystack_taggings, as: :taggable, dependent: :destroy
  has_many :haystack_tags, through: :haystack_taggings

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
needle_in_a_haystack-1.0.8 lib/needle_in_a_haystack/concerns/taggable.rb
needle_in_a_haystack-1.0.7 lib/needle_in_a_haystack/concerns/taggable.rb
needle_in_a_haystack-1.0.6 lib/needle_in_a_haystack/concerns/taggable.rb