Class: Cassanity::ArgumentGenerators::Columns

Inherits:
Object
  • Object
show all
Defined in:
lib/cassanity/argument_generators/columns.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Columns



7
8
9
# File 'lib/cassanity/argument_generators/columns.rb', line 7

def initialize(args = {})
  @where_clause = args.fetch(:where_clause) { WhereClause.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
# File 'lib/cassanity/argument_generators/columns.rb', line 12

def call(args = {})
  where = {}
  variables = []
  cql = 'SELECT * FROM system.schema_columns'

  if (keyspace_name = args[:keyspace_name])
    where[:keyspace_name] = keyspace_name
  end

  if (column_family_name = args[:column_family_name])
    where[:columnfamily_name] = column_family_name
  end

  where_cql, *where_variables = @where_clause.call(where: where)
  cql << where_cql
  variables.concat(where_variables)

  [cql, *variables]
end