Class: TwoWaySQL::Result
- Inherits:
-
Object
- Object
- TwoWaySQL::Result
- Defined in:
- lib/twowaysql/template.rb
Overview
TwoWaySQL::Result represents merge result of template and data. it contains SQL string with placeholders, and bound variables associated with placeholders.
Usage
merged = template.merge(:job => "HOGE", :deptno => 30)
merged.sql #=> "SELECT * FROM emp WHERE job = ? AND deptno = ?"
merged.bound_variables #=> ["HOGE", 30]
Instance Method Summary collapse
-
#bound_variables ⇒ Object
(also: #vars)
return array of variables which indices are corresponding to placeholders.
-
#initialize(context) ⇒ Result
constructor
A new instance of Result.
-
#sql ⇒ Object
return merge result SQL with placeholders (question mark).
Constructor Details
#initialize(context) ⇒ Result
Returns a new instance of Result.
73 74 75 |
# File 'lib/twowaysql/template.rb', line 73 def initialize(context) @context = context end |
Instance Method Details
#bound_variables ⇒ Object Also known as: vars
return array of variables which indices are corresponding to placeholders.
Return
merge result SQL with placeholders
91 92 93 |
# File 'lib/twowaysql/template.rb', line 91 def bound_variables @context.bound_variables end |
#sql ⇒ Object
return merge result SQL with placeholders (question mark).
Return
merge result SQL with placeholders
82 83 84 |
# File 'lib/twowaysql/template.rb', line 82 def sql @context.sql end |