Module: ScopedSearch::QueryBuilder::AST::LogicalOperatorNode

Defined in:
lib/scoped_search/query_builder.rb

Overview

Defines the to_sql method for AST AND/OR operators

Instance Method Summary collapse

Instance Method Details

#to_sql(builder, definition, &block) ⇒ Object



472
473
474
475
# File 'lib/scoped_search/query_builder.rb', line 472

def to_sql(builder, definition, &block)
  fragments = children.map { |c| c.to_sql(builder, definition, &block) }.map { |sql| "(#{sql})" unless sql.blank? }.compact
  fragments.empty? ? nil : "#{fragments.join(" #{operator.to_s.upcase} ")}"
end