Class: Cassandra::Mocks::Statement
- Inherits:
-
Object
- Object
- Cassandra::Mocks::Statement
- Defined in:
- lib/cassandra_mocks/statement.rb,
lib/cassandra_mocks/statement/token.rb,
lib/cassandra_mocks/statement/tokenizer.rb,
lib/cassandra_mocks/statement/arithmetic.rb,
lib/cassandra_mocks/statement/comparitor.rb
Defined Under Namespace
Classes: Arithmetic, Comparitor, Token, Tokenizer
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#cql ⇒ Object
readonly
Returns the value of attribute cql.
Instance Method Summary collapse
- #==(rhs) ⇒ Object
- #bind(*args) ⇒ Object
- #fill_params(params) ⇒ Object
-
#initialize(cql, args) ⇒ Statement
constructor
A new instance of Statement.
Constructor Details
#initialize(cql, args) ⇒ Statement
Returns a new instance of Statement.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cassandra_mocks/statement.rb', line 6 def initialize(cql, args) @cql = cql @input_args = param_queue(args) type_token = next_token @action = type_token.type if type_token.create? create_type_token = next_token if create_type_token.table? @action = :create_table parse_create_table else @action = :create_keyspace @args = {keyspace: next_token.value} end elsif type_token.truncate? parse_truncate_query elsif type_token.drop? if next_token.keyspace? @action = :drop_keyspace @args = {keyspace: next_token.value} else @action = :drop_table parse_truncate_query end elsif type_token.insert? parse_insert_query elsif type_token.update? parse_update_query elsif type_token.select? parse_select_query elsif type_token.delete? next_token parse_table_and_filter end end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
4 5 6 |
# File 'lib/cassandra_mocks/statement.rb', line 4 def action @action end |
#args ⇒ Object
Returns the value of attribute args.
4 5 6 |
# File 'lib/cassandra_mocks/statement.rb', line 4 def args @args end |
#cql ⇒ Object
Returns the value of attribute cql.
4 5 6 |
# File 'lib/cassandra_mocks/statement.rb', line 4 def cql @cql end |
Instance Method Details
#==(rhs) ⇒ Object
65 66 67 68 69 |
# File 'lib/cassandra_mocks/statement.rb', line 65 def ==(rhs) rhs.is_a?(Statement) && rhs.action == action && rhs.args == args end |
#bind(*args) ⇒ Object
61 62 63 |
# File 'lib/cassandra_mocks/statement.rb', line 61 def bind(*args) fill_params(args) end |
#fill_params(params) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cassandra_mocks/statement.rb', line 43 def fill_params(params) Statement.allocate.tap do |statement| statement.cql = cql statement.action = action statement.args = args.dup params = param_queue(params) case action when :insert parameterize_args!(:values, params, statement) when :select, :delete parameterize_args!(:filter, params, statement) when :update parameterize_args!(:values, params, statement) parameterize_args!(:filter, params, statement) end end end |