Module: PgTags::Taggable::ClassMethod

Defined in:
lib/pg_tags/taggable.rb

Instance Method Summary collapse

Instance Method Details

#has_tags(tag_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pg_tags/taggable.rb', line 8

def has_tags(tag_name)

  #== Scopes
  scope :"with_any_#{tag_name}", ->(tags){ where("#{tag_name} && ARRAY[?]::varchar[]", parser.parse(tags)) }
  # with_all_#{tag_name}
  # with_only_#{tag_name}
  # with_related_#{tag_name}
  # without_any_#{tag_name}
  # without_all_#{tag_name}

  self.class.class_eval do

    #== Class methods
    define_method :"all_#{tag_name}" do |options = {}, &block|
      "viewing all #{tag_name}"
    end

    # all_#{tag_name}s
    # {tag_name}s_cloud
    # related_#{tag_name}_to
    # most_used_#{tag_name}s
    # least_used_#{tag_name}s

  end
end