Class: IfElse
- Inherits:
-
Object
- Object
- IfElse
- Defined in:
- lib/lilit_sql.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #decl_sql ⇒ Object
-
#initialize(cond, true_result, false_result) ⇒ IfElse
constructor
A new instance of IfElse.
- #ref_sql ⇒ Object
- #state ⇒ Object
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_sql ⇒ Object
652 653 654 |
# File 'lib/lilit_sql.rb', line 652 def decl_sql ref_sql end |
#ref_sql ⇒ Object
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 |
#state ⇒ Object
660 661 662 |
# File 'lib/lilit_sql.rb', line 660 def state instance_variables.map { |variable| instance_variable_get variable } end |