Class: Mincer::PgSearch::SearchEngines::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/mincer/processors/pg_search/search_engines/array.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #search_statements

Instance Method Summary collapse

Methods inherited from Base

#arel_group, #engine_sym, #initialize, #prepared_search_statements, #quote, #rank, #sanitize_column, #sanitize_string, #sanitize_string_quoted, #search_engine_statements

Methods included from Mincer::Processors::Helpers

#join_expressions

Constructor Details

This class inherits a constructor from Mincer::PgSearch::SearchEngines::Base

Instance Method Details

#conditionsObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mincer/processors/pg_search/search_engines/array.rb', line 6

def conditions
  return nil unless prepared_search_statements.any?
  arel_group do
    conditions = prepared_search_statements.map do |search_statement|
      if search_statement.pattern = args[search_statement.param_name]
        terms_delimiter = search_statement.options[:any_word] ? '&&' : '@>'
        arel_group(Arel::Nodes::InfixOperation.new(terms_delimiter, document_for(search_statement), query_for(search_statement)))
      end
    end
    join_expressions(conditions, :or)
  end
end