Class: IfElse

Inherits:
Object
  • Object
show all
Defined in:
lib/lilit_sql.rb

Instance Method Summary collapse

Constructor Details

#initialize(cond, true_result, false_result) ⇒ IfElse

Returns a new instance of IfElse.



479
480
481
482
483
# File 'lib/lilit_sql.rb', line 479

def initialize(cond, true_result, false_result)
  @condition = cond
  @true_result = true_result
  @false_result = false_result
end

Instance Method Details

#==(other) ⇒ Object



493
494
495
# File 'lib/lilit_sql.rb', line 493

def ==(other)
  other.class == self.class && other.state == self.state
end

#decl_sqlObject



489
490
491
# File 'lib/lilit_sql.rb', line 489

def decl_sql
  ref_sql
end

#ref_sqlObject



485
486
487
# File 'lib/lilit_sql.rb', line 485

def ref_sql
  "if(#{@condition.ref_sql}, #{@true_result.ref_sql}, #{@false_result.ref_sql})"
end

#stateObject



497
498
499
# File 'lib/lilit_sql.rb', line 497

def state
  self.instance_variables.map { |variable| self.instance_variable_get variable }
end