Class: ROM::Cassandra::Relation

Inherits:
Relation
  • Object
show all
Defined in:
lib/rom/cassandra/relation.rb

Overview

Relation subclass of Cassandra adapter

Examples:

class Users < ROM::Relation[:cassandra]
  def last_ten_admins
    select(:id, :name)
      .where(role: "admin")
      .using(consistency: :quorum)
      .order(:name, :desc)
      .limit(10)
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRelation

Returns a new instance of Relation.



33
34
35
36
37
38
# File 'lib/rom/cassandra/relation.rb', line 33

def initialize(*)
  super
  return if (@source = options[:source])
  @source  = dataset
  @dataset = dataset.get
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



78
79
80
# File 'lib/rom/cassandra/relation.rb', line 78

def method_missing(name, *args)
  reload dataset.public_send(name, *args)
end

Instance Attribute Details

#sourceROM::Cassandra::Dataset (readonly)

Returns The source dataset before `get` method has been applied.

Returns:



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

def source
  @source
end

Instance Method Details

#batch_queryROM::Cassandra::Relation

Returns the relation whose source is restricted by `#delete` lazy query



68
69
70
# File 'lib/rom/cassandra/relation.rb', line 68

def batch_query
  reload source.batch
end

#delete_queryROM::Cassandra::Relation

Returns the relation whose source is restricted by `#delete` lazy query



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

def delete_query
  reload source.delete
end

#insert_queryROM::Cassandra::Relation

Returns the relation whose source is restricted by `#insert` lazy query



44
45
46
# File 'lib/rom/cassandra/relation.rb', line 44

def insert_query
  reload source.insert
end

#update_queryROM::Cassandra::Relation

Returns the relation whose source is restricted by `#update` lazy query



52
53
54
# File 'lib/rom/cassandra/relation.rb', line 52

def update_query
  reload source.update
end