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(statements) ⇒ 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.
- #statement_with_options(stmt, options) ⇒ Object
-
#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.nil? && @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(statements) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 51 def execute_batchable(statements) if defined?(@batch_statements) && @batch_statements @batch_statements += statements else execute_batch(statements) 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 |
#statement_with_options(stmt, options) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cassandra_object/adapters/abstract_adapter.rb', line 40 def (stmt, ) if .present? with_stmt = .split(',').map do |o| "#{o}" end.join(' AND ') stmt = "#{stmt} WITH #{with_stmt}" end stmt 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 |