Method: Cql::Model::Query.cql_identifier

Defined in:
lib/cql/model/query.rb

.cql_identifier(value) ⇒ Object

Transform a Ruby object into its CQL identifier representation.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cql/model/query.rb', line 32

def cql_identifier(value)
  # TODO UUID, Time, ...
  case value
  when Symbol, String
    if value =~ IDENTIFIER
      value.to_s
    else
      "#{DQ}#{value.gsub(DQ, DQDQ)}#{DQ}"
    end
  when Numeric, TrueClass, FalseClass
    "#{DQ}#{cql_value(value)}#{DQ}"
  else
    raise Cql::Model::SyntaxError, "Cannot convert #{value.class} to a CQL identifier"
  end
end