Class: Cassandra::Statements::Simple
- Inherits:
-
Object
- Object
- Cassandra::Statements::Simple
- Includes:
- Cassandra::Statement
- Defined in:
- lib/cassandra/statements/simple.rb
Instance Attribute Summary collapse
-
#cql ⇒ String
readonly
Original cql used to prepare this statement.
-
#params ⇒ Array<Object>
readonly
A list of positional parameters for the cql.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
(also: #==)
Whether the statements are equal.
-
#initialize(cql, params = nil) ⇒ Simple
constructor
A new instance of Simple.
-
#inspect ⇒ String
A CLI-friendly simple statement representation.
Constructor Details
#initialize(cql, params = nil) ⇒ Simple
Note:
Positional arguments for simple statements are only supported starting with Apache Cassandra 2.0 and above.
Note:
Named arguments for simple statements are only supported starting with Apache Cassandra 2.1 and above.
Returns a new instance of Simple.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cassandra/statements/simple.rb', line 45 def initialize(cql, params = nil) Util.assert_instance_of(::String, cql) { "cql must be a string, #{cql.inspect} given" } params ||= EMPTY_LIST if params.is_a?(::Hash) params_names = [] params = params.each_with_object([]) do |(name, value), params| params_names << name params << value end else Util.assert_instance_of(::Array, params) { "params must be an Array or a Hash, #{params.inspect} given" } params_names = EMPTY_LIST end @cql = cql @params = params @params_types = params.map {|value| Util.guess_type(value)} @params_names = params_names end |
Instance Attribute Details
#cql ⇒ String (readonly)
Returns original cql used to prepare this statement.
25 26 27 |
# File 'lib/cassandra/statements/simple.rb', line 25 def cql @cql end |
#params ⇒ Array<Object> (readonly)
Returns a list of positional parameters for the cql.
27 28 29 |
# File 'lib/cassandra/statements/simple.rb', line 27 def params @params end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Returns whether the statements are equal.
74 75 76 77 78 |
# File 'lib/cassandra/statements/simple.rb', line 74 def eql?(other) other.is_a?(Simple) && @cql == other.cql && @params == other.params end |
#inspect ⇒ String
Returns a CLI-friendly simple statement representation.
68 69 70 |
# File 'lib/cassandra/statements/simple.rb', line 68 def inspect "#<#{self.class.name}:0x#{self.object_id.to_s(16)} @cql=#{@cql.inspect} @params=#{@params.inspect}>" end |