Class: ROM::Cassandra::Gateway
- Inherits:
-
Gateway
- Object
- Gateway
- ROM::Cassandra::Gateway
- Defined in:
- lib/rom/cassandra/gateway.rb
Overview
The gateway to the keyspace of the Cassandra cluster
Instance Attribute Summary collapse
-
#datasets ⇒ Hash
readonly
The list of registered datasets.
-
#session ⇒ ROM::Cassandra::Session
readonly
The current session.
Instance Method Summary collapse
-
#[](name) ⇒ ROM::Cassandra::Dataset
Returns the registered dataset.
-
#dataset(name) ⇒ ROM::Cassandra::Dataset
Registers a new dataset.
-
#dataset?(name) ⇒ Boolean
Checks whether the dataset is registered.
-
#initialize(*options) ⇒ Gateway
constructor
Initializes the ROM gateway to the Cassandra cluster.
-
#migrate(options = {}) ⇒ undefined
Migrates the Cassandra cluster to given version.
-
#options ⇒ Hash
The options of the initialized session.
Constructor Details
Instance Attribute Details
#datasets ⇒ Hash (readonly)
Returns The list of registered datasets.
23 24 25 |
# File 'lib/rom/cassandra/gateway.rb', line 23 def datasets @datasets end |
#session ⇒ ROM::Cassandra::Session (readonly)
Returns The current session.
17 18 19 |
# File 'lib/rom/cassandra/gateway.rb', line 17 def session @session end |
Instance Method Details
#[](name) ⇒ ROM::Cassandra::Dataset
Returns the registered dataset
76 77 78 |
# File 'lib/rom/cassandra/gateway.rb', line 76 def [](name) datasets[name.to_sym] end |
#dataset(name) ⇒ ROM::Cassandra::Dataset
Registers a new dataset
66 67 68 |
# File 'lib/rom/cassandra/gateway.rb', line 66 def dataset(name) @datasets[name.to_sym] = Dataset.new(session, *split(name)) end |
#dataset?(name) ⇒ Boolean
Checks whether the dataset is registered
86 87 88 |
# File 'lib/rom/cassandra/gateway.rb', line 86 def dataset?(name) self[name] ? true : false end |
#migrate(options = {}) ⇒ undefined
Migrates the Cassandra cluster to given version
97 98 99 100 101 102 |
# File 'lib/rom/cassandra/gateway.rb', line 97 def migrate( = {}) settings = .select { |key| [:path, :logger].include? key } target = .select { |key| key.equal? :version } Migrations::Migrator.new(session, settings).apply(target) end |
#options ⇒ Hash
The options of the initialized session
53 54 55 |
# File 'lib/rom/cassandra/gateway.rb', line 53 def session.uri end |