Class: Mincer::Processors::PgSearch::SearchStatement

Inherits:
Object
  • Object
show all
Defined in:
lib/mincer/processors/pg_search/search_statement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(columns, options = {}) ⇒ SearchStatement

Returns a new instance of SearchStatement.



8
9
10
# File 'lib/mincer/processors/pg_search/search_statement.rb', line 8

def initialize(columns, options = {})
  @columns, @options = columns, ::ActiveSupport::HashWithIndifferentAccess.new(options)
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



5
6
7
# File 'lib/mincer/processors/pg_search/search_statement.rb', line 5

def columns
  @columns
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/mincer/processors/pg_search/search_statement.rb', line 5

def options
  @options
end

#patternObject Also known as: terms

Returns the value of attribute pattern.



5
6
7
# File 'lib/mincer/processors/pg_search/search_statement.rb', line 5

def pattern
  @pattern
end

Instance Method Details

#dictionaryObject



19
20
21
# File 'lib/mincer/processors/pg_search/search_statement.rb', line 19

def dictionary
  options[:dictionary] || Mincer.config.pg_search.fulltext_engine[:dictionary]
end

#param_nameObject



27
28
29
# File 'lib/mincer/processors/pg_search/search_statement.rb', line 27

def param_name
  options[:param_name] || Mincer.config.pg_search.param_name
end

#sanitizers(type = :all) ⇒ Object



12
13
14
15
16
17
# File 'lib/mincer/processors/pg_search/search_statement.rb', line 12

def sanitizers(type = :all)
  @sanitizers ||= {}
  @sanitizers[type] ||= Sanitizer::AVAILABLE_SANITIZERS.select do |sanitizer|
    options[sanitizer].is_a?(Hash) && [:query, :document].include?(type) ? options[sanitizer][type] : options[sanitizer]
  end
end

#thresholdObject



23
24
25
# File 'lib/mincer/processors/pg_search/search_statement.rb', line 23

def threshold
  options[:threshold] || Mincer.config.pg_search.trigram_engine[:threshold]
end