Class: Metka::QueryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/metka/query_builder.rb

Instance Method Summary collapse

Instance Method Details

#call(model, columns, tags, options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/metka/query_builder.rb', line 10

def call(model, columns, tags, options)
  strategy = options_to_strategy(options)

  query = join(options[:join_operator]) {
    columns.map do |column|
      build_query(strategy, model, column, tags)
    end
  }

  if options[:exclude].present?
    Arel::Nodes::Not.new(query)
  else
    query
  end
end