Class Sequel::SQL::CaseExpression
In: lib/sequel_core/sql.rb
Parent: GenericExpression

Represents an SQL CASE expression, used for conditions.

Methods

new   to_s  

Attributes

conditions  [R]  An array of all two pairs with the first element specifying the condition and the second element specifying the result.
default  [R]  The default value if no conditions are true
expression  [R]  The expression to test the conditions against

Public Class methods

Create an object with the given conditions and default value.

[Source]

     # File lib/sequel_core/sql.rb, line 507
507:       def initialize(conditions, default, expression = nil)
508:         raise(Sequel::Error, 'CaseExpression conditions must be an array with all_two_pairs') unless Array === conditions and conditions.all_two_pairs?
509:         @conditions, @default, @expression = conditions, default, expression
510:       end

Public Instance methods

Delegate the creation of the resulting SQL to the given dataset, since it may be database dependent.

[Source]

     # File lib/sequel_core/sql.rb, line 514
514:       def to_s(ds)
515:         ds.case_expression_sql(self)
516:       end

[Validate]