Class: CouchRest::Model::Base::OrmAdapter
- Inherits:
-
OrmAdapter::Base
- Object
- OrmAdapter::Base
- CouchRest::Model::Base::OrmAdapter
- Defined in:
- lib/orm_adapter_couchrest_model/couchrest_model.rb
Instance Method Summary collapse
- #column_names ⇒ Object
- #create!(attributes = {}) ⇒ Object
- #destroy(object) ⇒ Object
- #find_all(options = {}) ⇒ Object
- #find_first(options = {}) ⇒ Object
- #get(id) ⇒ Object
- #get!(id) ⇒ Object
Instance Method Details
#column_names ⇒ Object
9 10 11 |
# File 'lib/orm_adapter_couchrest_model/couchrest_model.rb', line 9 def column_names klass.properties end |
#create!(attributes = {}) ⇒ Object
45 46 47 |
# File 'lib/orm_adapter_couchrest_model/couchrest_model.rb', line 45 def create!(attributes = {}) klass.create!(attributes) end |
#destroy(object) ⇒ Object
49 50 51 |
# File 'lib/orm_adapter_couchrest_model/couchrest_model.rb', line 49 def destroy(object) object.destroy if valid_object?(object) end |
#find_all(options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/orm_adapter_couchrest_model/couchrest_model.rb', line 33 def find_all( = {}) conditions, order, limit, offset = extract_conditions!() if conditions.empty? klass.all(:limit => limit, :skip => offset).all elsif conditions.keys.first == :id klass.get(conditions.values.first) else view = klass.send("by_#{conditions.keys.first}") view.key(conditions.values.first).limit(limit).skip(offset).all end end |
#find_first(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/orm_adapter_couchrest_model/couchrest_model.rb', line 21 def find_first( = {}) conditions, order, limit, offset = extract_conditions!() if conditions.empty? klass.first elsif conditions.keys.first == :id klass.get(conditions.values.first) else view = klass.send("by_#{conditions.keys.first}") view.key(conditions.values.first).limit(1).first end end |
#get(id) ⇒ Object
17 18 19 |
# File 'lib/orm_adapter_couchrest_model/couchrest_model.rb', line 17 def get(id) klass.get(wrap_key(id)) end |
#get!(id) ⇒ Object
13 14 15 |
# File 'lib/orm_adapter_couchrest_model/couchrest_model.rb', line 13 def get!(id) klass.get!(wrap_key(id)) end |