Class: DatastaxRails::Cql::CreateKeyspace
- Defined in:
- lib/datastax_rails/cql/create_keyspace.rb
Overview
CQL Generation for CREATE KEYSPACE
Instance Method Summary collapse
-
#initialize(ks_name) ⇒ CreateKeyspace
constructor
A new instance of CreateKeyspace.
- #strategy_class(sc) ⇒ Object
- #strategy_options(so) ⇒ Object
- #to_cql ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(ks_name) ⇒ CreateKeyspace
Returns a new instance of CreateKeyspace.
5 6 7 8 |
# File 'lib/datastax_rails/cql/create_keyspace.rb', line 5 def initialize(ks_name) @ks_name = ks_name @strategy_options = {} end |
Instance Method Details
#strategy_class(sc) ⇒ Object
10 11 12 13 |
# File 'lib/datastax_rails/cql/create_keyspace.rb', line 10 def strategy_class(sc) @strategy_class = sc self end |
#strategy_options(so) ⇒ Object
15 16 17 18 |
# File 'lib/datastax_rails/cql/create_keyspace.rb', line 15 def (so) @strategy_options.merge!(so) self end |
#to_cql ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/datastax_rails/cql/create_keyspace.rb', line 20 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 |