Class: ActsAsExplorable::Element::In

Inherits:
Base
  • Object
show all
Defined in:
lib/acts_as_explorable/element/in.rb

Overview

Generates a where clause to look up the searched string in the given columns

Instance Attribute Summary

Attributes included from ActsAsExplorable::Element

#full_query, #model, #parameters, #query_parts, #query_string, #query_type

Instance Method Summary collapse

Methods included from ActsAsExplorable::Element

build, #execute, #initialize

Instance Method Details

#after_initObject



6
7
8
# File 'lib/acts_as_explorable/element/in.rb', line 6

def after_init
  @query_type = :where
end

#renderObject



10
11
12
13
14
15
16
# File 'lib/acts_as_explorable/element/in.rb', line 10

def render
  @parameters.each do |f|
    @query_parts <<
      table[f.to_sym].matches_any(@query_string.map { |q| "%#{q}%" })
  end
  @full_query = @query_parts.inject(:or)
end