Module: QueryBuilder::CQL::Operators
- Extended by:
- Transproc::Registry
- Included in:
- Modifiers::Base, Statements::Base
- Defined in:
- lib/query_builder/cql/operators.rb,
lib/query_builder/cql/operators/cql.rb,
lib/query_builder/cql/operators/cql_gt.rb,
lib/query_builder/cql/operators/cql_in.rb,
lib/query_builder/cql/operators/cql_lt.rb,
lib/query_builder/cql/operators/cql_dec.rb,
lib/query_builder/cql/operators/cql_gte.rb,
lib/query_builder/cql/operators/cql_inc.rb,
lib/query_builder/cql/operators/cql_lte.rb,
lib/query_builder/cql/operators/cql_map.rb,
lib/query_builder/cql/operators/cql_set.rb,
lib/query_builder/cql/operators/cql_ttl.rb,
lib/query_builder/cql/operators/cql_full.rb,
lib/query_builder/cql/operators/cql_keys.rb,
lib/query_builder/cql/operators/cql_list.rb,
lib/query_builder/cql/operators/cql_token.rb,
lib/query_builder/cql/operators/cql_tuple.rb,
lib/query_builder/cql/operators/cql_frozen.rb,
lib/query_builder/cql/operators/cql_element.rb,
lib/query_builder/cql/operators/cql_entries.rb,
lib/query_builder/cql/operators/cql_literal.rb,
lib/query_builder/cql/operators/cql_composite.rb,
lib/query_builder/cql/operators/cql_writetime.rb,
lib/query_builder/cql/operators/cql_token_value.rb,
lib/query_builder/cql/operators/cql_tuple_value.rb
Overview
The collection of CQL-specific operators (building blocks for statements)
Class Method Summary collapse
-
.cql(*parts) ⇒ String
Provides CQL statement from chunks.
-
.cql_composite(*columns) ⇒ String
Returns a description for the composite partition key.
-
.cql_dec(column, value) ⇒ String
Describes decrementing of the column.
-
.cql_element(column, key) ⇒ String
Returns a description for element of CQL collection.
-
.cql_entries(column) ⇒ String
Describes entries index.
-
.cql_frozen(value) ⇒ String
Marks value as frozen.
-
.cql_full(column) ⇒ String
Describes full frozen collection index.
-
.cql_gt(column, value) ⇒ String
Describes ‘greater than’ operator.
-
.cql_gte(column, value) ⇒ String
Describes ‘greater than or equal’ operator.
-
.cql_in(column, *values) ⇒ String
Returns IN condition.
-
.cql_inc(column, value) ⇒ String
Describes incrementing of the column.
-
.cql_keys(column) ⇒ String
Describes keys index.
-
.cql_list(value) ⇒ String
Returns the CQL LIST definition.
-
.cql_literal(value) ⇒ String
Converts value to CQL literal.
-
.cql_lt(column, value) ⇒ String
Describes ‘less than’ operator.
-
.cql_lte(column, value) ⇒ String
Describes ‘less than or equal’ operator.
-
.cql_map(*values) ⇒ String
Returns the CQL MAP definition.
-
.cql_set(value) ⇒ String
Returns the CQL SET definition.
-
.cql_token(type) ⇒ String
Returns the CQL TOKEN() definition.
-
.cql_token_value(value) ⇒ String
Returns value of CQL TOKEN.
-
.cql_ttl(column) ⇒ String
Describes TTL() function.
-
.cql_tuple(*types) ⇒ String
Returns the CQL TUPLE definition.
-
.cql_tuple_value(*values) ⇒ String
Returns value of CQL tuple.
-
.cql_writetime(column) ⇒ String
Describes WRITETIME() function.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object (private)
19 20 21 |
# File 'lib/query_builder/cql/operators.rb', line 19 def method_missing(name, *args) Operators[name, *args] end |
Class Method Details
.cql(*parts) ⇒ String
Provides CQL statement from chunks
16 17 18 19 20 21 |
# File 'lib/query_builder/cql/operators/cql.rb', line 16 def self.cql(*parts) parts .flatten .reject { |item| item.nil? || item.empty? } .join(" ") << ";" end |
.cql_composite(*columns) ⇒ String
Returns a description for the composite partition key
16 17 18 |
# File 'lib/query_builder/cql/operators/cql_composite.rb', line 16 def self.cql_composite(*columns) "(#{columns.join(", ")})" end |
.cql_dec(column, value) ⇒ String
Describes decrementing of the column
17 18 19 |
# File 'lib/query_builder/cql/operators/cql_dec.rb', line 17 def self.cql_dec(column, value) "#{column} = #{column} - #{value}" end |
.cql_element(column, key) ⇒ String
Returns a description for element of CQL collection
19 20 21 |
# File 'lib/query_builder/cql/operators/cql_element.rb', line 19 def self.cql_element(column, key) "#{column}[#{cql_literal(key)}]" end |
.cql_entries(column) ⇒ String
Describes entries index
16 17 18 |
# File 'lib/query_builder/cql/operators/cql_entries.rb', line 16 def self.cql_entries(column) "ENTRIES(#{column})" end |
.cql_frozen(value) ⇒ String
Marks value as frozen
16 17 18 |
# File 'lib/query_builder/cql/operators/cql_frozen.rb', line 16 def self.cql_frozen(value) "FROZEN <#{value}>" end |
.cql_full(column) ⇒ String
Describes full frozen collection index
16 17 18 |
# File 'lib/query_builder/cql/operators/cql_full.rb', line 16 def self.cql_full(column) "FULL(#{column})" end |
.cql_gt(column, value) ⇒ String
Describes ‘greater than’ operator
19 20 21 |
# File 'lib/query_builder/cql/operators/cql_gt.rb', line 19 def self.cql_gt(column, value) "#{column} > #{cql_literal(value)}" end |
.cql_gte(column, value) ⇒ String
Describes ‘greater than or equal’ operator
19 20 21 |
# File 'lib/query_builder/cql/operators/cql_gte.rb', line 19 def self.cql_gte(column, value) "#{column} >= #{cql_literal(value)}" end |
.cql_in(column, *values) ⇒ String
Returns IN condition
19 20 21 |
# File 'lib/query_builder/cql/operators/cql_in.rb', line 19 def self.cql_in(column, *values) "#{column} IN (#{values.map { |value| cql_literal(value) }.join(", ")})" end |
.cql_inc(column, value) ⇒ String
Describes incrementing of the column
17 18 19 |
# File 'lib/query_builder/cql/operators/cql_inc.rb', line 17 def self.cql_inc(column, value) "#{column} = #{column} + #{value}" end |
.cql_keys(column) ⇒ String
Describes keys index
16 17 18 |
# File 'lib/query_builder/cql/operators/cql_keys.rb', line 16 def self.cql_keys(column) "KEYS(#{column})" end |
.cql_list(value) ⇒ String
Returns the CQL LIST definition
17 18 19 |
# File 'lib/query_builder/cql/operators/cql_list.rb', line 17 def self.cql_list(value) "LIST<#{value}>" end |
.cql_literal(value) ⇒ String
Converts value to CQL literal
19 20 21 22 23 24 25 26 |
# File 'lib/query_builder/cql/operators/cql_literal.rb', line 19 def cql_literal(value) return "NaN" if nan?(value) return "Infinity" if infinity?(value) return value.to_s if unchanged?(value) return cql_literal_array(value) if array?(value) return cql_literal_hash(value) if hash?(value) quote(value) end |
.cql_lt(column, value) ⇒ String
Describes ‘less than’ operator
19 20 21 |
# File 'lib/query_builder/cql/operators/cql_lt.rb', line 19 def self.cql_lt(column, value) "#{column} < #{cql_literal(value)}" end |
.cql_lte(column, value) ⇒ String
Describes ‘less than or equal’ operator
19 20 21 |
# File 'lib/query_builder/cql/operators/cql_lte.rb', line 19 def self.cql_lte(column, value) "#{column} <= #{cql_literal(value)}" end |
.cql_map(*values) ⇒ String
Returns the CQL MAP definition
20 21 22 23 |
# File 'lib/query_builder/cql/operators/cql_map.rb', line 20 def self.cql_map(*values) key, value = values.flatten "MAP<#{key}, #{value}>" end |
.cql_set(value) ⇒ String
Returns the CQL SET definition
17 18 19 |
# File 'lib/query_builder/cql/operators/cql_set.rb', line 17 def self.cql_set(value) "SET<#{value}>" end |
.cql_token(type) ⇒ String
Returns the CQL TOKEN() definition
17 18 19 |
# File 'lib/query_builder/cql/operators/cql_token.rb', line 17 def self.cql_token(type) "TOKEN(#{type})" end |
.cql_token_value(value) ⇒ String
Returns value of CQL TOKEN
19 20 21 |
# File 'lib/query_builder/cql/operators/cql_token_value.rb', line 19 def self.cql_token_value(value) "TOKEN(#{cql_literal(value)})" end |
.cql_ttl(column) ⇒ String
Describes TTL() function
16 17 18 |
# File 'lib/query_builder/cql/operators/cql_ttl.rb', line 16 def self.cql_ttl(column) "TTL(#{column})" end |
.cql_tuple(*types) ⇒ String
Returns the CQL TUPLE definition
17 18 19 |
# File 'lib/query_builder/cql/operators/cql_tuple.rb', line 17 def self.cql_tuple(*types) "TUPLE<#{types.join(", ")}>" end |
.cql_tuple_value(*values) ⇒ String
Returns value of CQL tuple
19 20 21 |
# File 'lib/query_builder/cql/operators/cql_tuple_value.rb', line 19 def self.cql_tuple_value(*values) "(#{values.flatten.map { |value| cql_literal(value) }.join(", ")})" end |
.cql_writetime(column) ⇒ String
Describes WRITETIME() function
16 17 18 |
# File 'lib/query_builder/cql/operators/cql_writetime.rb', line 16 def self.cql_writetime(column) "WRITETIME(#{column})" end |