Class: Syntropy::DB::Store
- Inherits:
-
Object
- Object
- Syntropy::DB::Store
- Defined in:
- lib/syntropy/db/store.rb
Overview
The Store class represents a data store based on one or more tables, and connected to a database connection pool.
Instance Method Summary collapse
- #execute(sql) ⇒ Object
-
#initialize(connection_pool) ⇒ Store
constructor
A new instance of Store.
- #query(sql) ⇒ Object
- #query_single_row(sql) ⇒ Object
- #query_single_value(sql) ⇒ Object
- #transaction ⇒ Object
Constructor Details
#initialize(connection_pool) ⇒ Store
Returns a new instance of Store.
8 9 10 |
# File 'lib/syntropy/db/store.rb', line 8 def initialize(connection_pool) @connection_pool = connection_pool end |
Instance Method Details
#execute(sql) ⇒ Object
24 25 26 |
# File 'lib/syntropy/db/store.rb', line 24 def execute(sql, *, **) @connection_pool.with_db { it.execute(sql, *, **) } end |
#query(sql) ⇒ Object
12 13 14 |
# File 'lib/syntropy/db/store.rb', line 12 def query(sql, *, **) @connection_pool.with_db { it.query(sql, *, **) } end |
#query_single_row(sql) ⇒ Object
16 17 18 |
# File 'lib/syntropy/db/store.rb', line 16 def query_single_row(sql, *, **) @connection_pool.with_db { it.query_single(sql, *, **) } end |
#query_single_value(sql) ⇒ Object
20 21 22 |
# File 'lib/syntropy/db/store.rb', line 20 def query_single_value(sql, *, **) @connection_pool.with_db { it.query_single_splat(sql, *, **) } end |
#transaction ⇒ Object
28 29 30 |
# File 'lib/syntropy/db/store.rb', line 28 def transaction(&) @connection_pool.with_db(&) end |