Module: ROM::Cassandra::Commands

Included in:
Batch, Create, Delete, Update
Defined in:
lib/rom/cassandra/commands.rb,
lib/rom/cassandra/commands/batch.rb,
lib/rom/cassandra/commands/create.rb,
lib/rom/cassandra/commands/delete.rb,
lib/rom/cassandra/commands/update.rb

Overview

The collection of Cassandra-specific ROM commands

Defined Under Namespace

Classes: Batch, Create, Delete, Update

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



37
38
39
40
# File 'lib/rom/cassandra/commands.rb', line 37

def method_missing(name, *args)
  updated_relation = relation.public_send(name, *args)
  self.class.new updated_relation, initial: nil
end

Class Method Details

.included(klass) ⇒ Object



12
13
14
15
# File 'lib/rom/cassandra/commands.rb', line 12

def self.included(klass)
  klass.__send__ :adapter, :cassandra
  klass.__send__ :option, :initial, default: true
end

Instance Method Details

#execute(command = self) ⇒ Array

Implements the execute method of the ‘ROM::Command` abstract class

Parameters:

  • command (ROM::Command) (defaults to: self)

    The updated command

Returns:

  • (Array)

    The empty array (Cassandra doesn’t select rows when writes data).



31
32
33
# File 'lib/rom/cassandra/commands.rb', line 31

def execute(command = self)
  command.to_a
end

#initializeObject

Restricts the relation by a corresponding request



19
20
21
22
# File 'lib/rom/cassandra/commands.rb', line 19

def initialize(*)
  super
  @relation = relation.public_send(restriction) if options.fetch(:initial)
end