class RailsServersideDatatables::IfThen

Public Class Methods

new( testexpr, comparison_val, thenexpr, elseexpr ) click to toggle source
# File lib/rails_serverside_datatables/expressions.rb, line 19
def initialize( testexpr, comparison_val, thenexpr, elseexpr )
  expression = ExprTreeNode.new('', Type::OPERATOR ) # Concat the statements only

  expression.add_argument raw( 'CASE' )
  expression.add_argument testexpr

  if comparison_val.nil?
    expression.add_argument raw( 'IS NULL' )
    comparison_val = raw( true )
  end

  expression.add_argument raw( 'WHEN' )
  expression.add_argument comparison_val
  expression.add_argument raw( 'THEN' )
  expression.add_argument thenexpr
  expression.add_argument raw( 'ELSE' )
  expression.add_argument elseexpr
  expression.add_argument raw( 'END' )

  @expression = expression
end