Sha256: c9e1f31451d2b926cc4fb3023db4b260c20d0d551fff87ab3afadf98c84fc18b
Contents?: true
Size: 977 Bytes
Versions: 1
Compression:
Stored size: 977 Bytes
Contents
require 'cassanity/argument_generators/with_clause' module Cassanity module ArgumentGenerators class KeyspaceCreate def initialize(args = {}) @with_clause = args.fetch(:with_clause) { WithClause.new } end # Internal def call(args = {}) options, variables = [], [] name = args.fetch(:keyspace_name) cql = "CREATE KEYSPACE #{name}" replication = args.fetch(:replication, {}) if replication.empty? || replication[:class] !~ /NetworkTopologyStrategy/ replication = default_replication_options.merge(replication) end with_cql, *with_variables = @with_clause.call(with: { replication: replication }) cql << with_cql variables.concat(with_variables) [cql, *variables] end # Private def default_replication_options { class: 'SimpleStrategy', replication_factor: 1, } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cassanity-0.6.0 | lib/cassanity/argument_generators/keyspace_create.rb |