Class: Cequel::Metal::RowSpecification Private
- Inherits:
-
Object
- Object
- Cequel::Metal::RowSpecification
- Defined in:
- lib/cequel/metal/row_specification.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Encapsulates a row specification (‘WHERE` clause) constructed from a column ane one or more values to match
Instance Attribute Summary collapse
-
#column ⇒ Symbol
readonly
private
Column name.
-
#value ⇒ Object, Array
readonly
private
Value or values to match.
Class Method Summary collapse
-
.build(column_values) ⇒ Array<RowSpecification>
private
Build one or more row specifications.
Instance Method Summary collapse
-
#cql ⇒ String
private
Row specification as CQL fragment.
-
#initialize(column, value) ⇒ RowSpecification
constructor
private
A new instance of RowSpecification.
Constructor Details
#initialize(column, value) ⇒ RowSpecification
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RowSpecification.
30 31 32 |
# File 'lib/cequel/metal/row_specification.rb', line 30 def initialize(column, value) @column, @value = column, value end |
Instance Attribute Details
#column ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns column name.
22 23 24 |
# File 'lib/cequel/metal/row_specification.rb', line 22 def column @column end |
#value ⇒ Object, Array (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns value or values to match.
24 25 26 |
# File 'lib/cequel/metal/row_specification.rb', line 24 def value @value end |
Class Method Details
.build(column_values) ⇒ Array<RowSpecification>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build one or more row specifications
17 18 19 |
# File 'lib/cequel/metal/row_specification.rb', line 17 def self.build(column_values) column_values.map { |column, value| new(column, value) } end |
Instance Method Details
#cql ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns row specification as CQL fragment.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cequel/metal/row_specification.rb', line 37 def cql case @value when Array if @value.length == 1 ["#{@column} = ?", @value.first] else ["#{@column} IN (?)", @value] end else ["#{@column} = ?", @value] end end |