Class: Cassanity::ArgumentGenerators::KeyspaceCreate
- Inherits:
-
Object
- Object
- Cassanity::ArgumentGenerators::KeyspaceCreate
- Defined in:
- lib/cassanity/argument_generators/keyspace_create.rb
Instance Method Summary collapse
-
#call(args = {}) ⇒ Object
Internal.
-
#default_replication_options ⇒ Object
Private.
-
#initialize(args = {}) ⇒ KeyspaceCreate
constructor
A new instance of KeyspaceCreate.
Constructor Details
#initialize(args = {}) ⇒ KeyspaceCreate
Returns a new instance of KeyspaceCreate.
7 8 9 |
# File 'lib/cassanity/argument_generators/keyspace_create.rb', line 7 def initialize(args = {}) @with_clause = args.fetch(:with_clause) { WithClause.new } end |
Instance Method Details
#call(args = {}) ⇒ Object
Internal
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cassanity/argument_generators/keyspace_create.rb', line 12 def call(args = {}) , variables = [], [] name = args.fetch(:keyspace_name) cql = "CREATE KEYSPACE #{name}" replication = args.fetch(:replication, {}) if replication.empty? || replication[:class] !~ /NetworkTopologyStrategy/ replication = .merge(replication) end with_cql, *with_variables = @with_clause.call(with: { replication: replication }) cql << with_cql variables.concat(with_variables) [cql, *variables] end |
#default_replication_options ⇒ Object
Private
31 32 33 34 35 36 |
# File 'lib/cassanity/argument_generators/keyspace_create.rb', line 31 def { class: 'SimpleStrategy', replication_factor: 1, } end |