Class: DatastaxRails::Cql::CreateKeyspace

Inherits:
Base show all
Defined in:
lib/datastax_rails/cql/create_keyspace.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Base

#execute, #using

Constructor Details

#initialize(ks_name) ⇒ CreateKeyspace

Returns a new instance of CreateKeyspace.



4
5
6
7
# File 'lib/datastax_rails/cql/create_keyspace.rb', line 4

def initialize(ks_name)
  @ks_name = ks_name
  @strategy_options = {}
end

Instance Method Details

#strategy_class(sc) ⇒ Object



9
10
11
12
# File 'lib/datastax_rails/cql/create_keyspace.rb', line 9

def strategy_class(sc)
  @strategy_class = sc
  self
end

#strategy_options(so) ⇒ Object



14
15
16
17
# File 'lib/datastax_rails/cql/create_keyspace.rb', line 14

def strategy_options(so)
  @strategy_options.merge!(so)
  self
end

#to_cqlObject



19
20
21
22
23
24
25
26
27
# File 'lib/datastax_rails/cql/create_keyspace.rb', line 19

def to_cql
  stmt = "CREATE KEYSPACE #{@ks_name} WITH REPLICATION = {'class' : '#{@strategy_class}'"

  @strategy_options.each do |key, value|
    stmt << ", '#{key}' : '#{value}'"
  end
  stmt << '}'
  stmt
end