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.



642
643
644
645
646
# File 'lib/lilit_sql.rb', line 642

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

Instance Method Details

#==(other) ⇒ Object



656
657
658
# File 'lib/lilit_sql.rb', line 656

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

#decl_sqlObject



652
653
654
# File 'lib/lilit_sql.rb', line 652

def decl_sql
  ref_sql
end

#ref_sqlObject



648
649
650
# File 'lib/lilit_sql.rb', line 648

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

#stateObject



660
661
662
# File 'lib/lilit_sql.rb', line 660

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