class ROM::Cassandra::Dataset
The dataset describes a table of the Cassandra
cluster
@api private
Attributes
@!attribute [r] keyspace
@return [Symbol] The name of the current keyspace
@!attribute [r] query
@return [QueryBuilder::Statement] The lazy query to the current table
@!attribute [r] session
@return [ROM::Cassandra::Session] The open session to a Cassandra
cluster
@!attribute [r] table
@return [Symbol] The name of the current table
Public Class Methods
Initializes the dataset for given column family and command options
@param [ROM::Cassandra::Session] session @param [#to_sym] keyspace @param [#to_sym] table @param [ROM::Cassandra::Query] query
@api private
# File lib/rom/cassandra/dataset.rb, line 47 def initialize(session, keyspace, table, query = nil) @session = session @keyspace = keyspace.to_sym if keyspace @table = table.to_sym if table @query = query || Query.new.keyspace(keyspace).table(table) end
Public Instance Methods
Returns the new dataset carriyng the batch query
The batch query doesn’t restricted by any table or keyspace
@return [ROM::Relation::Dataset]
# File lib/rom/cassandra/dataset.rb, line 60 def batch reload nil, nil, Query.new.batch end
Sends the [#query] to Cassandra
and iterates through results
@return [Enumerator]
@yieldparam [Hash] tuples from the dataset @yieldreturn [self] itself
# File lib/rom/cassandra/dataset.rb, line 81 def each return to_enum unless block_given? session.call(query).each { |item| yield(item) } end
Returns new dataset with ‘select` method applied to the [#query]
@param [Array, Hash, nil] args
@return [ROM::Relation::Dataset]
# File lib/rom/cassandra/dataset.rb, line 70 def get(*args) reload keyspace, table, query.select(*args) end
Private Instance Methods
# File lib/rom/cassandra/dataset.rb, line 92 def method_missing(name, *args) reload keyspace, table, query.public_send(name, *args) end
# File lib/rom/cassandra/dataset.rb, line 88 def reload(*args) self.class.new(session, *args) end
# File lib/rom/cassandra/dataset.rb, line 96 def respond_to_missing?(name, *) query.respond_to?(name) end