Class: MiniSql::Postgres::PreparedConnection
- Inherits:
-
Connection
- Object
- Connection
- Connection
- MiniSql::Postgres::PreparedConnection
- Defined in:
- lib/mini_sql/postgres/prepared_connection.rb
Instance Attribute Summary collapse
-
#unprepared ⇒ Object
readonly
Returns the value of attribute unprepared.
Attributes inherited from Connection
#param_encoder, #raw_connection, #type_map
Instance Method Summary collapse
- #build(_) ⇒ Object
- #deserializer_cache ⇒ Object
-
#initialize(unprepared_connection) ⇒ PreparedConnection
constructor
A new instance of PreparedConnection.
- #prepared(condition = true) ⇒ Object
Methods inherited from Connection
default_deserializer_cache, #escape_string, #exec, #query, #query_array, #query_decorator, #query_each, #query_each_hash, #query_hash, #query_single, type_map, typemap
Methods inherited from Connection
#escape_string, #exec, get, #query, #query_decorator, #query_each, #query_each_hash, #query_hash, #query_single, #to_sql
Constructor Details
#initialize(unprepared_connection) ⇒ PreparedConnection
Returns a new instance of PreparedConnection.
9 10 11 12 13 14 15 16 17 |
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 9 def initialize(unprepared_connection) @unprepared = unprepared_connection @raw_connection = unprepared_connection.raw_connection @type_map = unprepared_connection.type_map @param_encoder = unprepared_connection.param_encoder @prepared_cache = PreparedCache.new(@raw_connection) @param_binder = PreparedBinds.new end |
Instance Attribute Details
#unprepared ⇒ Object (readonly)
Returns the value of attribute unprepared.
7 8 9 |
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 7 def unprepared @unprepared end |
Instance Method Details
#build(_) ⇒ Object
19 20 21 |
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 19 def build(_) raise 'Builder can not be called on prepared connections, instead of `::MINI_SQL.prepared.build(sql).query` use `::MINI_SQL.build(sql).prepared.query`' end |
#deserializer_cache ⇒ Object
27 28 29 |
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 27 def deserializer_cache @unprepared.deserializer_cache end |
#prepared(condition = true) ⇒ Object
23 24 25 |
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 23 def prepared(condition = true) condition ? self : @unprepared end |