Class: PgExecArrayParams::Query
- Inherits:
-
Object
- Object
- PgExecArrayParams::Query
- Defined in:
- lib/pg_exec_array_params/query.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #binds ⇒ Object
- #columns ⇒ Object
- #exec_params(conn, *args) ⇒ Object
-
#initialize(query, args = []) ⇒ Query
constructor
A new instance of Query.
- #sql ⇒ Object
Constructor Details
#initialize(query, args = []) ⇒ Query
Returns a new instance of Query.
9 10 11 12 |
# File 'lib/pg_exec_array_params/query.rb', line 9 def initialize(query, args = []) @query = query @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
7 8 9 |
# File 'lib/pg_exec_array_params/query.rb', line 7 def args @args end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
7 8 9 |
# File 'lib/pg_exec_array_params/query.rb', line 7 def query @query end |
Instance Method Details
#binds ⇒ Object
22 23 24 |
# File 'lib/pg_exec_array_params/query.rb', line 22 def binds should_rebuild? ? (@binds ||= args.flatten(1)) : args end |
#columns ⇒ Object
26 27 28 |
# File 'lib/pg_exec_array_params/query.rb', line 26 def columns @columns || (rebuild_query! && @columns) end |
#exec_params(conn, *args) ⇒ Object
14 15 16 |
# File 'lib/pg_exec_array_params/query.rb', line 14 def exec_params(conn, *args) conn.exec_params(sql, binds, *args) end |
#sql ⇒ Object
18 19 20 |
# File 'lib/pg_exec_array_params/query.rb', line 18 def sql should_rebuild? ? (@sql || (rebuild_query! && @sql)) : query end |