class Cequel::Record::Bound
An upper or lower bound for a range query.
@abstract Subclasses must implement the `to_cql` method, and may override
the `operator` and `bind_value` methods.
@api private @since 1.0.0
Attributes
@return [Schema::Column] column bound applies to
@return value for bound
Public Class Methods
Create a bound object for the given column. This method returns an instance of the appropriate `Bound` subclass given the type of the column and the class of the value.
@param (see initialize) @return [Bound] instance of appropriate bound implementation
# File lib/cequel/record/bound.rb, line 26 def self.create(column, gt, inclusive, value) implementation = if column.partition_key? PartitionKeyBound elsif column.type?(:timeuuid) && !Cequel.uuid?(value) TimeuuidBound else ClusteringColumnBound end implementation.new(column, gt, inclusive, value) end
@param column [Schema::Column] column bound applies to @param gt [Boolean] `true` if this is a lower bound @param inclusive [Boolean] `true` if this is an inclusive bound @param value value for bound
# File lib/cequel/record/bound.rb, line 45 def initialize(column, gt, inclusive, value) @column, @gt, @inclusive, @value = column, gt, inclusive, value end
Public Instance Methods
@return [Boolean] `true` if this is an exclusive bound
# File lib/cequel/record/bound.rb, line 80 def exclusive? !inclusive? end
@return [Boolean] `true` if this is a lower bound
# File lib/cequel/record/bound.rb, line 59 def gt? !!@gt end
@return [Boolean] `true` if this is an inclusive bound
# File lib/cequel/record/bound.rb, line 73 def inclusive? !!@inclusive end
@return [Boolean] `true` if this is an upper bound
# File lib/cequel/record/bound.rb, line 66 def lt? !gt? end
@return [Array] pair containing CQL string and bind value
# File lib/cequel/record/bound.rb, line 52 def to_cql_with_bind_variables [to_cql, bind_value] end
Protected Instance Methods
# File lib/cequel/record/bound.rb, line 94 def base_operator lt? ? '<' : '>' end
# File lib/cequel/record/bound.rb, line 86 def bind_value column.cast(value) end
# File lib/cequel/record/bound.rb, line 90 def operator exclusive? ? base_operator : "#{base_operator}=" end