Sha256: a9f5918498b587b9466e0a06e4ddff4649b289f3d0ada0fbc69a7c93dc65eb4c

Contents?: true

Size: 368 Bytes

Versions: 9

Compression:

Stored size: 368 Bytes

Contents

module DiscoApp::Concerns::Taggable
  extend ActiveSupport::Concern

  def tags
    data[:tags].split(',').map(&:strip)
  end

  def add_tag(tag)
    data[:tags] = (tags + [tag]).uniq.join(',')
  end

  def remove_tag(tag)
    data[:tags] = (tags - [tag]).uniq.join(',')
  end

  def has_tag?(tag_to_check)
    tags.any? { |tag| tag.casecmp(tag_to_check) }
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
disco_app-0.13.5 app/models/disco_app/concerns/taggable.rb
disco_app-0.13.6 app/models/disco_app/concerns/taggable.rb
disco_app-0.13.7 app/models/disco_app/concerns/taggable.rb
disco_app-0.13.8 app/models/disco_app/concerns/taggable.rb
disco_app-0.14.1 app/models/disco_app/concerns/taggable.rb
disco_app-0.14.2 app/models/disco_app/concerns/taggable.rb
disco_app-0.14.3 app/models/disco_app/concerns/taggable.rb
disco_app-0.14.0 app/models/disco_app/concerns/taggable.rb
disco_app-0.13.6.pre.puma.pre.3 app/models/disco_app/concerns/taggable.rb