Class: Cassanity::ArgumentGenerators::ColumnFamilyUpdate
- Inherits:
-
Object
- Object
- Cassanity::ArgumentGenerators::ColumnFamilyUpdate
- Defined in:
- lib/cassanity/argument_generators/column_family_update.rb
Instance Method Summary collapse
-
#call(args = {}) ⇒ Object
Internal.
-
#initialize(args = {}) ⇒ ColumnFamilyUpdate
constructor
Internal.
Constructor Details
#initialize(args = {}) ⇒ ColumnFamilyUpdate
Internal
10 11 12 13 14 |
# File 'lib/cassanity/argument_generators/column_family_update.rb', line 10 def initialize(args = {}) @using_clause = args.fetch(:using_clause) { UsingClause.new } @set_clause = args.fetch(:set_clause) { SetClause.new } @where_clause = args.fetch(:where_clause) { WhereClause.new } end |
Instance Method Details
#call(args = {}) ⇒ Object
Internal
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cassanity/argument_generators/column_family_update.rb', line 17 def call(args = {}) name = args.fetch(:column_family_name) set = args.fetch(:set) where = args.fetch(:where) using = args[:using] || {} variables = [] if (keyspace_name = args[:keyspace_name]) name = "#{keyspace_name}.#{name}" end cql = "UPDATE #{name}" using_cql, *using_variables = @using_clause.call(using: using) cql << using_cql variables.concat(using_variables) set_cql, *set_variables = @set_clause.call(set: set) cql << set_cql variables.concat(set_variables) where_cql, *where_variables = @where_clause.call(where: where) cql << where_cql variables.concat(where_variables) [cql, *variables] end |