Class: ROM::Cassandra::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/cassandra/session.rb

Overview

Wraps the external driver, responsible for sending CQL requests to the Cassandra cluster

Constant Summary collapse

FORMAT =

The regexp, describing the format of the allowed address of the cluster

/\d{1,3}(\.\d{1,3}){3}(\:\d+)?/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*options) ⇒ Session

Initializes a session to given cluster

Parameters:

  • options (Hash)


25
26
27
28
# File 'lib/rom/cassandra/session.rb', line 25

def initialize(*options)
  @uri  = extract(*options)
  @conn = ::Cassandra.cluster(uri).connect
end

Instance Attribute Details

#uriHash (readonly)

Returns the settings for the session.

Returns:

  • (Hash)

    the settings for the session



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

def uri
  @uri
end

Instance Method Details

#call(query) ⇒ Array<Hash>

Sends the query to the Cassandra syncronously

Parameters:

  • query (#to_s)

Returns:

  • (Array<Hash>)


36
37
38
# File 'lib/rom/cassandra/session.rb', line 36

def call(query)
  @conn.execute(query.to_s).to_a
end