class Cequel::Metal::RowSpecification
Encapsulates a row specification (`WHERE` clause) constructed from a column ane one or more values to match
@api private
Attributes
column[R]
@return [Symbol] column name
value[R]
@return [Object, Array] value or values to match
Public Class Methods
build(column_values)
click to toggle source
Build one or more row specifications
@param column_values [Hash] map of column name to value or values @return [Array<RowSpecification>] collection of row specifications
# File lib/cequel/metal/row_specification.rb, line 16 def self.build(column_values) column_values.map { |column, value| new(column, value) } end
new(column, value)
click to toggle source
@param column [Symbol] column name @param value [Object,Array] value or values to match
# File lib/cequel/metal/row_specification.rb, line 29 def initialize(column, value) @column, @value = column, value end
Public Instance Methods
cql()
click to toggle source
@return [String] row specification as CQL fragment
# File lib/cequel/metal/row_specification.rb, line 36 def cql value = if Enumerable === @value && @value.count == 1 @value.first else @value end if Array === value ["#{@column} IN ?", value] else ["#{@column} = ?", value] end end