Class: ColumnSifter::Base::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/column_sifter/base/compiler.rb

Constant Summary collapse

TEMPORAL_TYPES =
%i[datetime date time].freeze

Instance Method Summary collapse

Constructor Details

#initialize(allowed_columns, model) ⇒ Compiler

Returns a new instance of Compiler.



8
9
10
11
# File 'lib/column_sifter/base/compiler.rb', line 8

def initialize(allowed_columns, model)
  @allowed_columns = allowed_columns
  @model = model
end

Instance Method Details

#compile(node) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/column_sifter/base/compiler.rb', line 13

def compile(node)
  case node[:type]
  when :and    then combine('AND', node[:children])
  when :or     then combine('OR', node[:children])
  when :not    then compile_not(node)
  when :cmp    then compile_cmp(node)
  when :in     then compile_in(node)
  when :is_null then compile_is_null(node)
  else
    raise ParseError, "unknown node: #{node[:type]}"
  end
end