class ROM::Cassandra::Session
Wraps the external driver, responsible for sending CQL requests to the Cassandra
cluster
Constants
- FORMAT
The regexp, describing the format of the allowed address of the cluster
Attributes
uri[R]
@!attribute [r] uri
@return [Hash] the settings for the session
Public Class Methods
new(*options)
click to toggle source
Initializes a session to given cluster
@param [Hash] options
# File lib/rom/cassandra/session.rb, line 25 def initialize(*options) @uri = extract(*options) @conn = ::Cassandra.cluster(uri).connect end
Public Instance Methods
call(query)
click to toggle source
Sends the query to the Cassandra
syncronously
@param [#to_s] query
@return [Array<Hash>]
# File lib/rom/cassandra/session.rb, line 36 def call(query) @conn.execute(query.to_s).to_a end
Private Instance Methods
extract(uri = { hosts: ["127.0.0.1"], port: 9042 }, hash = {})
click to toggle source
# File lib/rom/cassandra/session.rb, line 42 def extract(uri = { hosts: ["127.0.0.1"], port: 9042 }, hash = {}) return uri if uri.instance_of? Hash hosts, port = uri[FORMAT].split(":") { hosts: [hosts], port: port.to_i }.merge hash end