class Arel::Nodes::Case

Attributes

case[RW]
conditions[RW]
default[RW]

Public Instance Methods

==(other) click to toggle source
Alias for: eql?
else(expression) click to toggle source
# File lib/arel/nodes/case.rb, line 27
def else expression
  @default = Else.new Nodes.build_quoted(expression)
  self
end
eql?(other) click to toggle source
# File lib/arel/nodes/case.rb, line 43
def eql? other
  self.class == other.class &&
    self.case == other.case &&
    self.conditions == other.conditions &&
    self.default == other.default
end
Also aliased as: ==
hash() click to toggle source
# File lib/arel/nodes/case.rb, line 39
def hash
  [@case, @conditions, @default].hash
end
initialize_copy(other) click to toggle source
# File lib/arel/nodes/case.rb, line 32
def initialize_copy other
  super
  @case = @case.clone if @case
  @conditions = @conditions.map { |x| x.clone }
  @default = @default.clone if @default
end
then(expression) click to toggle source
# File lib/arel/nodes/case.rb, line 22
def then expression
  @conditions.last.right = Nodes.build_quoted(expression)
  self
end
when(condition, expression = nil) click to toggle source
# File lib/arel/nodes/case.rb, line 17
def when condition, expression = nil
  @conditions << When.new(Nodes.build_quoted(condition), expression)
  self
end

Public Class Methods

new(expression = nil, default = nil) click to toggle source
# File lib/arel/nodes/case.rb, line 11
def initialize expression = nil, default = nil
  @case = expression
  @conditions = []
  @default = default
end