class MiniSql::Sqlite::PreparedConnection
Attributes
unprepared[R]
Public Class Methods
new(unprepared_connection)
click to toggle source
# File lib/mini_sql/sqlite/prepared_connection.rb, line 9 def initialize(unprepared_connection) @unprepared = unprepared_connection @raw_connection = unprepared_connection.raw_connection @param_encoder = unprepared_connection.param_encoder @prepared_cache = PreparedCache.new(@raw_connection) @param_binder = PreparedBinds.new end
Public Instance Methods
build(_)
click to toggle source
# File lib/mini_sql/sqlite/prepared_connection.rb, line 18 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()
click to toggle source
# File lib/mini_sql/sqlite/prepared_connection.rb, line 26 def deserializer_cache @unprepared.deserializer_cache end
prepared(condition = true)
click to toggle source
# File lib/mini_sql/sqlite/prepared_connection.rb, line 22 def prepared(condition = true) condition ? self : @unprepared end
Private Instance Methods
run(sql, params) { |execute| ... }
click to toggle source
# File lib/mini_sql/sqlite/prepared_connection.rb, line 30 def run(sql, params) prepared_sql, binds, _bind_names = @param_binder.bind(sql, params) statement = @prepared_cache.prepare_statement(prepared_sql) statement.bind_params(binds) if block_given? yield statement.execute else statement.execute.to_a end end