Class: Believer::WhereClause
- Inherits:
-
Object
- Object
- Believer::WhereClause
- Includes:
- CqlHelper
- Defined in:
- lib/believer/where_clause.rb
Constant Summary
Constants included from CqlHelper
CqlHelper::CQL_TIMESTAMP_FORMAT
Instance Method Summary collapse
-
#initialize(*args) ⇒ WhereClause
constructor
A new instance of WhereClause.
- #to_cql ⇒ Object
Methods included from CqlHelper
#escape_special_chars, #to_cql_literal, #to_cql_properties, #to_hex_literal
Constructor Details
#initialize(*args) ⇒ WhereClause
Returns a new instance of WhereClause.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/believer/where_clause.rb', line 6 def initialize(*args) if args.any? if args[0].is_a?(Hash) @value_map = args[0] else @where_string = args[0] @bindings = args.slice(1, args.length - 1) end end end |
Instance Method Details
#to_cql ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/believer/where_clause.rb', line 17 def to_cql if @value_map && @value_map.any? return @value_map.keys.map {|k| create_expression(k, @value_map[k])}.join(' AND ') end binding_index = 0 ws = @where_string.gsub(/\?/) { |match| rep_val = to_cql_literal(@bindings[binding_index]) binding_index += 1 rep_val } ws end |