Module: Queries::Concerns::Tags

Extended by:
ActiveSupport::Concern
Defined in:
lib/queries/concerns/tags.rb

Overview

Helpers for queries that reference Identifier

Instance Method Summary collapse

Instance Method Details

#matching_keyword_idsObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/queries/concerns/tags.rb', line 20

def matching_keyword_ids
  return nil if keyword_ids.empty?
  k = table.name.classify.safe_constantize
  t = ::Tag.arel_table
  k.where(
    ::Tag.where(
      t[:tag_object_id].eq(table[:id]).and(
        t[:tag_object_type].eq(table.name.classify)).and(
          t[:keyword_id].eq_any(keyword_ids)
        )
    ).arel.exists
  )
end

#set_tags_params(params) ⇒ Object



11
12
13
# File 'lib/queries/concerns/tags.rb', line 11

def set_tags_params(params)
  @keyword_ids = params[:keyword_ids].blank? ? [] : params[:keyword_ids]
end

#tag_tableArel::Table

Returns:

  • (Arel::Table)


16
17
18
# File 'lib/queries/concerns/tags.rb', line 16

def tag_table 
  ::Tag.arel_table
end