class ROM::Cassandra::Gateway
The gateway to the keyspace of the Cassandra
cluster
@api public
Attributes
datasets[R]
@!attribute [r] datasets
@return [Hash] The list of registered datasets
session[R]
@!attribute [r] session
@return [ROM::Cassandra::Session] The current session
Public Class Methods
new(*options)
click to toggle source
Initializes the ROM
gateway to the Cassandra
cluster
@example
ROM::Cassandra::Gateway.new( hosts: ["10.0.1.1", "10.0.1.2"], port: 9042, username: "admin", password: "foo" )
@example
ROM::Cassandra::Gateway.new( "http://10.0.1.1:9042", username: "admin", password: "foo" )
@param [Hash] options
# File lib/rom/cassandra/gateway.rb, line 44 def initialize(*options) @session = Session.new(*options) @datasets = {} end
Public Instance Methods
[](name)
click to toggle source
dataset(name)
click to toggle source
Registers a new dataset
@example
dataset "foo.bar"
@param [#to_sym] name The full name of the table
@return [ROM::Cassandra::Dataset]
# File lib/rom/cassandra/gateway.rb, line 66 def dataset(name) @datasets[name.to_sym] = Dataset.new(session, *split(name)) end
dataset?(name)
click to toggle source
Checks whether the dataset is registered
@param (see dataset
)
@return [Boolean]
# File lib/rom/cassandra/gateway.rb, line 86 def dataset?(name) self[name] ? true : false end
migrate(options = {})
click to toggle source
Migrates the Cassandra
cluster to given version
@option (see ROM::Cassandra::Migrations::Migrator#new) @option options [Integer, nil] :version
@return [undefined]
# File lib/rom/cassandra/gateway.rb, line 97 def migrate(options = {}) settings = options.select { |key| [:path, :logger].include? key } target = options.select { |key| key.equal? :version } Migrations::Migrator.new(session, settings).apply(target) end
options()
click to toggle source
The options of the initialized session
@return [Hash]
# File lib/rom/cassandra/gateway.rb, line 53 def options session.uri end
Private Instance Methods
split(name)
click to toggle source
# File lib/rom/cassandra/gateway.rb, line 106 def split(name) list = name.to_s.split(".") return list if 2.equal? list.count fail ArgumentError.new "'#{name}' is not a valid full name of a table. " \ "Use format 'keyspace.table' with both keyspace and table parts." end