Class: Bmg::Sql::Processor::Constants
- Inherits:
-
Processor
- Object
- Processor
- Bmg::Sql::Processor::Constants
- Defined in:
- lib/bmg/sql/processor/constants.rb
Instance Attribute Summary collapse
-
#constants ⇒ Object
readonly
Returns the value of attribute constants.
Instance Method Summary collapse
-
#initialize(constants, builder) ⇒ Constants
constructor
A new instance of Constants.
- #on_select_list(sexpr) ⇒ Object
- #on_select_star(sexpr) ⇒ Object
- #on_set_operator(sexpr) ⇒ Object (also: #on_union, #on_except, #on_intersect)
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
#constants ⇒ Object (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
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 |