Class: Cequel::Record::OrmAdapter
- Inherits:
-
OrmAdapter::Base
- Object
- OrmAdapter::Base
- Cequel::Record::OrmAdapter
- Extended by:
- Forwardable
- Defined in:
- lib/cequel/record/orm_adapter.rb
Overview
ORM adapter for Cequel, the Ruby ORM for Cassandra
Instance Method Summary collapse
-
#column_names ⇒ Array<Symbol>
Names of columns on this model.
-
#create!(attributes = {}) ⇒ Cequel::Record
Create a new instance of the record class and save it to the database.
-
#destroy(record) ⇒ void
Destroy the given record.
-
#find_all(options = {}) ⇒ Array<Cequel::Record>
Find all records with the given conditions and limit.
-
#find_first(options = {}) ⇒ Cequel::Record
Find the first record instance with the given conditions.
-
#get(key_values) ⇒ Cequel::Record
A record instance corresponding to this primary key or nil if not present.
-
#get!(key_values) ⇒ Cequel::Record
A record instance corresponding to this primary key.
Instance Method Details
#column_names ⇒ Array<Symbol>
Returns names of columns on this model.
19 20 21 |
# File 'lib/cequel/record/orm_adapter.rb', line 19 def column_names klass.columns.map { |column| column.name } end |
#create!(attributes = {}) ⇒ Cequel::Record
Create a new instance of the record class and save it to the database
87 |
# File 'lib/cequel/record/orm_adapter.rb', line 87 def_delegator :klass, :create! |
#destroy(record) ⇒ void
This method returns an undefined value.
Destroy the given record
95 96 97 |
# File 'lib/cequel/record/orm_adapter.rb', line 95 def destroy(record) record.destroy end |
#find_all(options = {}) ⇒ Array<Cequel::Record>
Find all records with the given conditions and limit
74 75 76 |
# File 'lib/cequel/record/orm_adapter.rb', line 74 def find_all( = {}) construct_scope().to_a end |
#find_first(options = {}) ⇒ Cequel::Record
Find the first record instance with the given conditions
60 61 62 |
# File 'lib/cequel/record/orm_adapter.rb', line 60 def find_first( = {}) construct_scope().first end |
#get(key_values) ⇒ Cequel::Record
Returns a record instance corresponding to this primary key or nil if not present.
44 45 46 47 48 |
# File 'lib/cequel/record/orm_adapter.rb', line 44 def get(key_values) get!(key_values) rescue Cequel::Record::RecordNotFound nil end |
#get!(key_values) ⇒ Cequel::Record
Returns a record instance corresponding to this primary key.
32 33 34 |
# File 'lib/cequel/record/orm_adapter.rb', line 32 def get!(key_values) klass.find(*key_values) end |