Class: ROM::Cassandra::Dataset Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rom/cassandra/dataset.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.

The dataset describes a table of the Cassandra cluster

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, keyspace, table, query = nil) ⇒ Dataset

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.

Initializes the dataset for given column family and command options

Parameters:



47
48
49
50
51
52
# 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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)

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.



92
93
94
# File 'lib/rom/cassandra/dataset.rb', line 92

def method_missing(name, *args)
  reload keyspace, table, query.public_send(name, *args)
end

Instance Attribute Details

#keyspaceSymbol (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 The name of the current keyspace.

Returns:

  • (Symbol)

    The name of the current keyspace



24
25
26
# File 'lib/rom/cassandra/dataset.rb', line 24

def keyspace
  @keyspace
end

#queryQueryBuilder::Statement (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 The lazy query to the current table.

Returns:

  • (QueryBuilder::Statement)

    The lazy query to the current table



36
37
38
# File 'lib/rom/cassandra/dataset.rb', line 36

def query
  @query
end

#sessionROM::Cassandra::Session (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 The open session to a Cassandra cluster.

Returns:



18
19
20
# File 'lib/rom/cassandra/dataset.rb', line 18

def session
  @session
end

#tableSymbol (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 The name of the current table.

Returns:

  • (Symbol)

    The name of the current table



30
31
32
# File 'lib/rom/cassandra/dataset.rb', line 30

def table
  @table
end

Instance Method Details

#batchROM::Relation::Dataset

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 the new dataset carriyng the batch query

The batch query doesn't restricted by any table or keyspace

Returns:

  • (ROM::Relation::Dataset)


60
61
62
# File 'lib/rom/cassandra/dataset.rb', line 60

def batch
  reload nil, nil, Query.new.batch
end

#each {|tuples| ... } ⇒ Enumerator

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.

Sends the [#query] to Cassandra and iterates through results

Yield Parameters:

  • tuples (Hash)

    from the dataset

Yield Returns:

  • (self)

    itself

Returns:

  • (Enumerator)


81
82
83
84
# File 'lib/rom/cassandra/dataset.rb', line 81

def each
  return to_enum unless block_given?
  session.call(query).each { |item| yield(item) }
end

#get(*args) ⇒ ROM::Relation::Dataset

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 new dataset with `select` method applied to the [#query]

Parameters:

  • args (Array, Hash, nil)

Returns:

  • (ROM::Relation::Dataset)


70
71
72
# File 'lib/rom/cassandra/dataset.rb', line 70

def get(*args)
  reload keyspace, table, query.select(*args)
end