Class: TwoWaySQL::IfNode

Inherits:
Node
  • Object
show all
Defined in:
lib/twowaysql/node.rb

Instance Method Summary collapse

Constructor Details

#initialize(cond, tstmt, fstmt) ⇒ IfNode

Returns a new instance of IfNode.



104
105
106
107
108
# File 'lib/twowaysql/node.rb', line 104

def initialize(cond, tstmt, fstmt)
  @condition = cond
  @tstmt = tstmt
  @fstmt = fstmt
end

Instance Method Details

#accept(ctx) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/twowaysql/node.rb', line 109

def accept(ctx)
  if do_eval(ctx, @condition)
    exec_list(@tstmt, ctx)
    ctx.enable!
  elsif @fstmt
    exec_list(@fstmt, ctx)
    ctx.enable!
  end
end