Class: TwoWaySQL::ParenBindVariableNode
- Defined in:
- lib/twowaysql/node.rb
Instance Method Summary collapse
- #accept(ctx) ⇒ Object
- #bind_values(ctx, ary) ⇒ Object
-
#initialize(exp) ⇒ ParenBindVariableNode
constructor
A new instance of ParenBindVariableNode.
Constructor Details
#initialize(exp) ⇒ ParenBindVariableNode
Returns a new instance of ParenBindVariableNode.
168 169 170 |
# File 'lib/twowaysql/node.rb', line 168 def initialize(exp) @exp = exp end |
Instance Method Details
#accept(ctx) ⇒ Object
171 172 173 174 175 176 177 178 179 180 |
# File 'lib/twowaysql/node.rb', line 171 def accept(ctx) result = do_eval(ctx, @exp) return if result.nil? ##TODO: is there any better way to handle array-like structure? if result.respond_to?('to_ary') bind_values(ctx, result.to_ary) else ctx.add_value(result) end end |
#bind_values(ctx, ary) ⇒ Object
181 182 183 184 185 186 |
# File 'lib/twowaysql/node.rb', line 181 def bind_values(ctx, ary) return if ary.empty? ctx.add_sql("(") ctx.add_values(ary) ctx.add_sql(")") end |