Class: Believer::Insert
- Includes:
- CqlHelper
- Defined in:
- lib/believer/insert.rb
Constant Summary
Constants included from CqlHelper
CqlHelper::CQL_TIMESTAMP_FORMAT
Instance Attribute Summary collapse
-
#values ⇒ Object
Returns the value of attribute values.
Attributes inherited from Command
#consistency_level, #record_class
Instance Method Summary collapse
Methods included from CqlHelper
#escape_special_chars, #to_cql_literal, #to_cql_properties, #to_hex_literal
Methods inherited from Command
#can_execute?, #clone, #command_name, #consistency, #execute, #execution_options, #execution_options=, #initialize, #override_execution_options, #query_attributes
Constructor Details
This class inherits a constructor from Believer::Command
Instance Attribute Details
#values ⇒ Object
Returns the value of attribute values.
6 7 8 |
# File 'lib/believer/insert.rb', line 6 def values @values end |
Instance Method Details
#to_cql ⇒ Object
12 13 14 15 16 17 |
# File 'lib/believer/insert.rb', line 12 def to_cql attrs = @values.keys cols_def = "#{attrs.join(', ')}" vals_defs = attrs.map { |a| to_cql_literal(@values[a]) }.join(', ') "INSERT INTO #{@record_class.table_name} (#{cols_def}) VALUES (#{vals_defs})" end |