Class: CassandraObject::Adapters::AbstractAdapter
- Inherits:
-
Object
- Object
- CassandraObject::Adapters::AbstractAdapter
- Defined in:
- lib/cassandra_object/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 CassandraObject::Scope.
-
#update(table, id, attributes) ⇒ Object
Update an existing row.
Constructor Details
#initialize(config) ⇒ AbstractAdapter
Returns a new instance of AbstractAdapter.
5 6 7 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 5 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 4 def config @config end |
Instance Method Details
#batch ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 32 def batch @batch_statements = [] yield execute_batch(@batch_statements) if @batch_statements.any? ensure @batch_statements = nil end |
#batching? ⇒ Boolean
28 29 30 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 28 def batching? !@batch_statements.nil? end |
#delete(table, ids) ⇒ Object
Delete rows by an array of ids
22 23 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 22 def delete(table, ids) # abstract end |
#execute_batch(statements) ⇒ Object
abstract
25 26 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 25 def execute_batch(statements) # abstract end |
#execute_batchable(statement) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 40 def execute_batchable(statement) if @batch_statements @batch_statements << statement else execute statement end end |
#insert(table, id, attributes) ⇒ Object
Insert a new row
14 15 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 14 def insert(table, id, attributes) # abstract end |
#select(scope) ⇒ Object
Read records from a instance of CassandraObject::Scope
10 11 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 10 def select(scope) # abstract end |
#update(table, id, attributes) ⇒ Object
Update an existing row
18 19 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 18 def update(table, id, attributes) # abstract end |