Class: Bmg::Sql::Processor::Constants

Inherits:
Bmg::Sql::Processor show all
Defined in:
lib/bmg/sql/processor/constants.rb

Constant Summary

Constants inherited from Bmg::Sql::Processor

UnexpectedError

Instance Attribute Summary collapse

Attributes inherited from Bmg::Sql::Processor

#builder

Instance Method Summary collapse

Methods inherited from Bmg::Sql::Processor

#on_select_exp, #on_with_exp

Constructor Details

#initialize(constants, builder) ⇒ Constants

Returns a new instance of Constants.



6
7
8
9
# File 'lib/bmg/sql/processor/constants.rb', line 6

def initialize(constants, builder)
  super(builder)
  @constants = constants
end

Instance Attribute Details

#constantsObject (readonly)

Returns the value of attribute constants.



10
11
12
# File 'lib/bmg/sql/processor/constants.rb', line 10

def constants
  @constants
end

Instance Method Details

#on_select_list(sexpr) ⇒ Object



23
24
25
26
27
# File 'lib/bmg/sql/processor/constants.rb', line 23

def on_select_list(sexpr)
  sexpr + constants.each_pair.map{|(k,v)|
    builder.select_literal_item(v, k)
  }
end

#on_select_star(sexpr) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/bmg/sql/processor/constants.rb', line 19

def on_select_star(sexpr)
  raise NotImplementedError, "Constants on * is not supported"
end

#on_set_operator(sexpr) ⇒ Object Also known as: on_union, on_except, on_intersect



12
13
14
# File 'lib/bmg/sql/processor/constants.rb', line 12

def on_set_operator(sexpr)
  apply(builder.from_self(sexpr))
end