Class: Cequel::Record::Bound Abstract Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cequel/record/bound.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.

This class is abstract.

Subclasses must implement the `to_cql` method, and may override the `operator` and `bind_value` methods.

An upper or lower bound for a range query.

Since:

  • 1.0.0

Direct Known Subclasses

ClusteringColumnBound, PartitionKeyBound

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column, gt, inclusive, value) ⇒ Bound

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 Bound.

Parameters:

  • column (Schema::Column)

    column bound applies to

  • gt (Boolean)

    `true` if this is a lower bound

  • inclusive (Boolean)

    `true` if this is an inclusive bound

  • value

    value for bound

Since:

  • 1.0.0


46
47
48
# File 'lib/cequel/record/bound.rb', line 46

def initialize(column, gt, inclusive, value)
  @column, @gt, @inclusive, @value = column, gt, inclusive, value
end

Instance Attribute Details

#columnSchema::Column (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 bound applies to.

Returns:

Since:

  • 1.0.0


15
16
17
# File 'lib/cequel/record/bound.rb', line 15

def column
  @column
end

#valueObject (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 for bound.

Returns:

  • value for bound

Since:

  • 1.0.0


17
18
19
# File 'lib/cequel/record/bound.rb', line 17

def value
  @value
end

Class Method Details

.create(column, gt, inclusive, value) ⇒ Bound

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.

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.

Parameters:

  • column (Schema::Column)

    column bound applies to

  • gt (Boolean)

    `true` if this is a lower bound

  • inclusive (Boolean)

    `true` if this is an inclusive bound

  • value

    value for bound

Returns:

  • (Bound)

    instance of appropriate bound implementation

Since:

  • 1.0.0


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cequel/record/bound.rb', line 27

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

Instance Method Details

#exclusive?Boolean

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 `true` if this is an exclusive bound.

Returns:

  • (Boolean)

    `true` if this is an exclusive bound

Since:

  • 1.0.0


81
82
83
# File 'lib/cequel/record/bound.rb', line 81

def exclusive?
  !inclusive?
end

#gt?Boolean

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 `true` if this is a lower bound.

Returns:

  • (Boolean)

    `true` if this is a lower bound

Since:

  • 1.0.0


60
61
62
# File 'lib/cequel/record/bound.rb', line 60

def gt?
  !!@gt
end

#inclusive?Boolean

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 `true` if this is an inclusive bound.

Returns:

  • (Boolean)

    `true` if this is an inclusive bound

Since:

  • 1.0.0


74
75
76
# File 'lib/cequel/record/bound.rb', line 74

def inclusive?
  !!@inclusive
end

#lt?Boolean

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 `true` if this is an upper bound.

Returns:

  • (Boolean)

    `true` if this is an upper bound

Since:

  • 1.0.0


67
68
69
# File 'lib/cequel/record/bound.rb', line 67

def lt?
  !gt?
end

#to_cql_with_bind_variablesArray

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 pair containing CQL string and bind value.

Returns:

  • (Array)

    pair containing CQL string and bind value

Since:

  • 1.0.0


53
54
55
# File 'lib/cequel/record/bound.rb', line 53

def to_cql_with_bind_variables
  [to_cql, bind_value]
end