Class: Cassie::Support::StatementParser
- Defined in:
- lib/cassie/support/statement_parser.rb
Constant Summary collapse
- QUOTED_TYPES =
[:date, :time, :text, :timestamp, :inet, :ascii].freeze
Instance Attribute Summary collapse
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
Instance Method Summary collapse
- #bound_cql ⇒ Object
-
#initialize(statement) ⇒ StatementParser
constructor
A new instance of StatementParser.
- #params ⇒ Object
- #params_types ⇒ Object
- #to_cql ⇒ Object
Constructor Details
#initialize(statement) ⇒ StatementParser
7 8 9 |
# File 'lib/cassie/support/statement_parser.rb', line 7 def initialize(statement) @statement = statement end |
Instance Attribute Details
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
5 6 7 |
# File 'lib/cassie/support/statement_parser.rb', line 5 def statement @statement end |
Instance Method Details
#bound_cql ⇒ Object
11 12 13 |
# File 'lib/cassie/support/statement_parser.rb', line 11 def bound_cql statement.cql end |
#params ⇒ Object
15 16 17 |
# File 'lib/cassie/support/statement_parser.rb', line 15 def params statement.params end |
#params_types ⇒ Object
19 20 21 |
# File 'lib/cassie/support/statement_parser.rb', line 19 def params_types statement.params_types end |
#to_cql ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |