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

column[R]

@return [Schema::Column] column bound applies to

value[R]

@return value for bound

Public Class Methods

create(column, gt, inclusive, value) click to toggle source

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
new(column, gt, inclusive, value) click to toggle source

@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

exclusive?() click to toggle source

@return [Boolean] `true` if this is an exclusive bound

# File lib/cequel/record/bound.rb, line 80
def exclusive?
  !inclusive?
end
gt?() click to toggle source

@return [Boolean] `true` if this is a lower bound

# File lib/cequel/record/bound.rb, line 59
def gt?
  !!@gt
end
inclusive?() click to toggle source

@return [Boolean] `true` if this is an inclusive bound

# File lib/cequel/record/bound.rb, line 73
def inclusive?
  !!@inclusive
end
lt?() click to toggle source

@return [Boolean] `true` if this is an upper bound

# File lib/cequel/record/bound.rb, line 66
def lt?
  !gt?
end
to_cql_with_bind_variables() click to toggle source

@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

base_operator() click to toggle source
# File lib/cequel/record/bound.rb, line 94
def base_operator
  lt? ? '<' : '>'
end
bind_value() click to toggle source
# File lib/cequel/record/bound.rb, line 86
def bind_value
  column.cast(value)
end
operator() click to toggle source
# File lib/cequel/record/bound.rb, line 90
def operator
  exclusive? ? base_operator : "#{base_operator}="
end