Class: Task::DataInterface::CassandraAdapter
- Inherits:
-
Object
- Object
- Task::DataInterface::CassandraAdapter
- Defined in:
- lib/task/data_interface/cassandra_adapter.rb
Defined Under Namespace
Classes: TaskDeserializer
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#tasks_table_name ⇒ Object
readonly
Returns the value of attribute tasks_table_name.
Instance Method Summary collapse
- #all(task_list) ⇒ Object
- #delete(task_list, task_id) ⇒ Object
- #find(task_list, task_id) ⇒ Object
-
#initialize(opts = {}) ⇒ CassandraAdapter
constructor
A new instance of CassandraAdapter.
- #store(task) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ CassandraAdapter
Returns a new instance of CassandraAdapter.
12 13 14 15 |
# File 'lib/task/data_interface/cassandra_adapter.rb', line 12 def initialize(opts = {}) @client = opts[:client] @tasks_table_name = opts[:tasks_table_name] || :tasks end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/task/data_interface/cassandra_adapter.rb', line 7 def client @client end |
#tasks_table_name ⇒ Object (readonly)
Returns the value of attribute tasks_table_name.
7 8 9 |
# File 'lib/task/data_interface/cassandra_adapter.rb', line 7 def tasks_table_name @tasks_table_name end |
Instance Method Details
#all(task_list) ⇒ Object
35 36 37 |
# File 'lib/task/data_interface/cassandra_adapter.rb', line 35 def all(task_list) read_pipe.push(:task_list => task_list).value end |
#delete(task_list, task_id) ⇒ Object
30 31 32 |
# File 'lib/task/data_interface/cassandra_adapter.rb', line 30 def delete(task_list, task_id) client.delete(:tasks).where(:task_list => task_list, :id => task_id).execute end |
#find(task_list, task_id) ⇒ Object
39 40 41 |
# File 'lib/task/data_interface/cassandra_adapter.rb', line 39 def find(task_list, task_id) read_pipe.push(:task_list => task_list, :id => task_id).value.first end |
#store(task) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/task/data_interface/cassandra_adapter.rb', line 18 def store(task) pipeline = Pyper::Pipeline.new # Serialize the attributes to be stored pipeline << Pyper::Pipes::Model::AttributeSerializer.new # Store the serialized attributes in the tasks table pipeline << Pyper::Pipes::Cassandra::Writer.new(tasks_table_name, client) pipeline.push(task.as_hash) end |