Module: Bmg::Sql::CaseWhen
- Includes:
- Expr
- Defined in:
- lib/bmg/sql/nodes/case_when.rb
Constant Summary
Constants included
from Expr
Expr::AND, Expr::AS, Expr::COMMA, Expr::DOT, Expr::EQUAL, Expr::EXISTS, Expr::FALSE, Expr::GREATER, Expr::GREATER_OR_EQUAL, Expr::IN, Expr::LEFT_PARENTHESE, Expr::LESS, Expr::LESS_OR_EQUAL, Expr::NOT, Expr::NOT_EQUAL, Expr::OR, Expr::QUOTE, Expr::RIGHT_PARENTHESE, Expr::SPACE, Expr::TRUE
Instance Method Summary
collapse
Methods included from Expr
#each_child, #flatten, #group_by?, #join?, #limit_or_offset?, #order_by?, #ordering, #set_operator?, #with_insert, #with_push, #with_update
Instance Method Details
#is_computed? ⇒ Boolean
14
15
16
|
# File 'lib/bmg/sql/nodes/case_when.rb', line 14
def is_computed?
true
end
|
#operand ⇒ Object
6
7
8
|
# File 'lib/bmg/sql/nodes/case_when.rb', line 6
def operand
self[1]
end
|
#to_sql(buffer, dialect) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/bmg/sql/nodes/case_when.rb', line 18
def to_sql(buffer, dialect)
buffer << "CASE "
operand.to_sql(buffer, dialect)
whens.each do |(when_val, then_val)|
buffer << " WHEN "
when_val.to_sql(buffer, dialect)
buffer << " THEN "
then_val.to_sql(buffer, dialect)
end
buffer << " END"
buffer
end
|
#whens ⇒ Object
10
11
12
|
# File 'lib/bmg/sql/nodes/case_when.rb', line 10
def whens
self[2..-1].each_slice(2).to_a
end
|