class Cequel::Metal::Row

A result row from a CQL query. Acts as a hash of column names to values, but also exposes TTLs and writetimes

@since 1.0.0

Public Class Methods

from_result_row(result_row) click to toggle source

Encapsulate a result row from the driver

@param result_row [Hash] row from underlying driver @return [Row] encapsulated row

@api private

# File lib/cequel/metal/row.rb, line 18
def self.from_result_row(result_row)
  if result_row
    new.tap do |row|
      result_row.each_pair do |name, value|
        if name =~ /^(ttl|writetime)\((.+)\)$/
          if $1 == 'ttl' then row.set_ttl($2, value)
          else row.set_writetime($2, value)
          end
        else row[name] = value
        end
      end
    end
  end
end
new() click to toggle source

@api private

Calls superclass method
# File lib/cequel/metal/row.rb, line 36
def initialize
  super(ActiveSupport::HashWithIndifferentAccess.new)
  @ttls = ActiveSupport::HashWithIndifferentAccess.new
  @writetimes = ActiveSupport::HashWithIndifferentAccess.new
end

Public Instance Methods

set_ttl(column, value) click to toggle source

@private

# File lib/cequel/metal/row.rb, line 64
def set_ttl(column, value)
  @ttls[column] = value
end
set_writetime(column, value) click to toggle source

@private

# File lib/cequel/metal/row.rb, line 69
def set_writetime(column, value)
  @writetimes[column] = value
end
timestamp(column)
Alias for: writetime
ttl(column) click to toggle source

Get the TTL (time-to-live) of a column

@param column [Symbol] column name @return [Integer] TTL of column in seconds

# File lib/cequel/metal/row.rb, line 48
def ttl(column)
  @ttls[column]
end
writetime(column) click to toggle source

Get the writetime of a column

@param column [Symbol] column name @return [Integer] writetime of column in nanoseconds since epoch

# File lib/cequel/metal/row.rb, line 58
def writetime(column)
  @writetimes[column]
end
Also aliased as: timestamp