class Cassie::Support::StatementParser

Constants

QUOTED_TYPES

Attributes

statement[R]

Public Class Methods

new(statement) click to toggle source
# File lib/cassie/support/statement_parser.rb, line 7
def initialize(statement)
  @statement = statement
end

Public Instance Methods

bound_cql() click to toggle source
# File lib/cassie/support/statement_parser.rb, line 11
def bound_cql
  statement.cql
end
params() click to toggle source
# File lib/cassie/support/statement_parser.rb, line 15
def params
  statement.params
end
params_types() click to toggle source
# File lib/cassie/support/statement_parser.rb, line 19
def params_types
  statement.params_types
end
to_cql() click to toggle source
# File lib/cassie/support/statement_parser.rb, line 23
def to_cql
  cql = bound_cql.dup

  params_types.map.with_index do |type, i|
    cassandra_param = type.new(params[i])
    quoted_val = if QUOTED_TYPES.include? type.kind
      "'#{cassandra_param}'"
    else
      cassandra_param.to_s
    end

    cql.sub!("?", quoted_val)
  end
  cql
end