class Arel::Nodes::Case
Case
node
@example
switch.when(table[:x].gt(1), table[:y]).else(table[:z]) # CASE WHEN "table"."x" > 1 THEN "table"."y" ELSE "table"."z" END switch.when(table[:x].gt(1)).then(table[:y]).else(table[:z])
Attributes
conditions[R]
default[R]
Public Class Methods
new()
click to toggle source
# File lib/arel_extension/nodes/case.rb, line 21 def initialize @conditions = [] @default = nil end
Public Instance Methods
else(expression)
click to toggle source
# File lib/arel_extension/nodes/case.rb, line 36 def else(expression) @default = Else.new(expression) self end
then(expression)
click to toggle source
# File lib/arel_extension/nodes/case.rb, line 31 def then(expression) @conditions.last.right = expression self end
when(condition, expression = nil)
click to toggle source
# File lib/arel_extension/nodes/case.rb, line 26 def when(condition, expression = nil) @conditions << When.new(condition, expression) self end