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_strategy_class ⇒ Object
Private.
-
#default_strategy_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 29 30 31 32 33 34 35 36 37 |
# File 'lib/cassanity/argument_generators/keyspace_create.rb', line 12 def call(args = {}) , variables = [], [] name = args.fetch(:name) cql = "CREATE KEYSPACE #{name}" with = { strategy_class: default_strategy_class, strategy_options: , } if args[:strategy_class] with[:strategy_class] = args[:strategy_class] end if args[:strategy_options] args[:strategy_options].each do |key, value| with[:strategy_options][key] = value end end with_cql, *with_variables = @with_clause.call(with: with) cql << with_cql variables.concat(with_variables) [cql, *variables] end |
#default_strategy_class ⇒ Object
Private
40 41 42 |
# File 'lib/cassanity/argument_generators/keyspace_create.rb', line 40 def default_strategy_class 'SimpleStrategy' end |
#default_strategy_options ⇒ Object
Private
45 46 47 48 49 |
# File 'lib/cassanity/argument_generators/keyspace_create.rb', line 45 def { replication_factor: 1, } end |