Class: Superstore::Adapters::AbstractAdapter
- Inherits:
-
Object
- Object
- Superstore::Adapters::AbstractAdapter
- Defined in:
- lib/superstore/adapters/abstract_adapter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #batch ⇒ Object
- #batching? ⇒ Boolean
-
#delete(table, ids) ⇒ Object
Delete rows by an array of ids.
-
#execute_batch(statements) ⇒ Object
abstract.
- #execute_batchable(statement) ⇒ Object
-
#initialize(config) ⇒ AbstractAdapter
constructor
A new instance of AbstractAdapter.
-
#insert(table, id, attributes) ⇒ Object
Insert a new row.
-
#select(scope) ⇒ Object
Read records from a instance of Superstore::Scope.
-
#update(table, id, attributes) ⇒ Object
Update an existing row.
Constructor Details
#initialize(config) ⇒ AbstractAdapter
Returns a new instance of AbstractAdapter.
5 6 7 8 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 5 def initialize(config) @config = config @batch_statements = nil end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 4 def config @config end |
Instance Method Details
#batch ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 33 def batch @batch_statements = [] yield execute_batch(@batch_statements) if @batch_statements.any? ensure @batch_statements = nil end |
#batching? ⇒ Boolean
29 30 31 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 29 def batching? !@batch_statements.nil? end |
#delete(table, ids) ⇒ Object
Delete rows by an array of ids
23 24 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 23 def delete(table, ids) # abstract end |
#execute_batch(statements) ⇒ Object
abstract
26 27 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 26 def execute_batch(statements) # abstract end |
#execute_batchable(statement) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 41 def execute_batchable(statement) if @batch_statements @batch_statements << statement else execute statement end end |
#insert(table, id, attributes) ⇒ Object
Insert a new row
15 16 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 15 def insert(table, id, attributes) # abstract end |
#select(scope) ⇒ Object
Read records from a instance of Superstore::Scope
11 12 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 11 def select(scope) # abstract end |
#update(table, id, attributes) ⇒ Object
Update an existing row
19 20 |
# File 'lib/superstore/adapters/abstract_adapter.rb', line 19 def update(table, id, attributes) # abstract end |