Module: Alchemy::Taggable::ClassMethods

Defined in:
lib/alchemy/taggable.rb

Instance Method Summary collapse

Instance Method Details

#tag_countsObject

Returns all unique tags



43
44
45
46
# File 'lib/alchemy/taggable.rb', line 43

def tag_counts
  Gutentag::Tag.distinct.joins(:taggings)
    .where(gutentag_taggings: {taggable_type: name})
end

#tagged_with(names = [], **args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/alchemy/taggable.rb', line 26

def tagged_with(names = [], **args)
  if names.is_a? String
    names = names.split(/,\s*/)
  end

  unless args[:match]
    args[:match] = :all
  end

  if names.any?
    args[:names] = names
  end

  super(args)
end