Class: DataMapper::Adapters::Sqlite3Adapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- DataMapper::Adapters::Sqlite3Adapter
- Defined in:
- lib/data_mapper/adapters/sqlite3_adapter.rb
Defined Under Namespace
Constant Summary
Constants inherited from AbstractAdapter
AbstractAdapter::SYNTAX, AbstractAdapter::TYPES
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(configuration) ⇒ Sqlite3Adapter
constructor
A new instance of Sqlite3Adapter.
Methods inherited from AbstractAdapter
Constructor Details
#initialize(configuration) ⇒ Sqlite3Adapter
Returns a new instance of Sqlite3Adapter.
11 12 13 14 |
# File 'lib/data_mapper/adapters/sqlite3_adapter.rb', line 11 def initialize(configuration) super @connections = Support::ConnectionPool.new { Queries::Connection.new(@configuration) } end |
Instance Method Details
#connection ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/data_mapper/adapters/sqlite3_adapter.rb', line 16 def connection raise ArgumentError.new('Sqlite3Adapter#connection requires a block-parameter') unless block_given? begin @connections.hold { |connection| yield connection } rescue SQLite3::Exception => sle @configuration.log.fatal(sle) @connections.available_connections.each do |sock| begin sock.close rescue => se @configuration.log.error(se) end end @connections.available_connections.clear raise sle end end |