Class: TwoWaySQL::Result

Inherits:
Object
  • Object
show all
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

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_variablesObject 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

#sqlObject

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