Class: Cequel::Metal::Row
- Inherits:
-
ActiveSupport::HashWithIndifferentAccess
- Object
- ActiveSupport::HashWithIndifferentAccess
- Cequel::Metal::Row
- Defined in:
- lib/cequel/metal/row.rb
Overview
A result row from a CQL query. Acts as a hash of column names to values, but also exposes TTLs and writetimes
Class Method Summary collapse
-
.from_result_row(result_row) ⇒ Row
private
Encapsulate a result row from the driver.
Instance Method Summary collapse
-
#initialize ⇒ Row
constructor
private
A new instance of Row.
- #set_ttl(column, value) ⇒ Object
- #set_writetime(column, value) ⇒ Object
-
#ttl(column) ⇒ Integer
Get the TTL (time-to-live) of a column.
-
#writetime(column) ⇒ Integer
(also: #timestamp)
Get the writetime of a column.
Constructor Details
#initialize ⇒ Row
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 Row.
37 38 39 40 41 |
# File 'lib/cequel/metal/row.rb', line 37 def initialize super(ActiveSupport::HashWithIndifferentAccess.new) @ttls = ActiveSupport::HashWithIndifferentAccess.new @writetimes = ActiveSupport::HashWithIndifferentAccess.new end |
Class Method Details
.from_result_row(result_row) ⇒ Row
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.
Encapsulate a result row from the driver
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cequel/metal/row.rb', line 19 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 |
Instance Method Details
#set_ttl(column, value) ⇒ Object
65 66 67 |
# File 'lib/cequel/metal/row.rb', line 65 def set_ttl(column, value) @ttls[column] = value end |
#set_writetime(column, value) ⇒ Object
70 71 72 |
# File 'lib/cequel/metal/row.rb', line 70 def set_writetime(column, value) @writetimes[column] = value end |
#ttl(column) ⇒ Integer
Get the TTL (time-to-live) of a column
49 50 51 |
# File 'lib/cequel/metal/row.rb', line 49 def ttl(column) @ttls[column] end |
#writetime(column) ⇒ Integer Also known as: timestamp
Get the writetime of a column
59 60 61 |
# File 'lib/cequel/metal/row.rb', line 59 def writetime(column) @writetimes[column] end |