Class: SimplyStored::Couch::OrmAdapter
- Inherits:
-
OrmAdapter::Base
- Object
- OrmAdapter::Base
- SimplyStored::Couch::OrmAdapter
- Defined in:
- lib/orm_adapter/adapters/simply_stored.rb
Class Method Summary collapse
-
.except_classes ⇒ Object
Do not consider these to be part of the class list.
-
.model_classes ⇒ Object
Gets a list of the available models for this adapter.
Instance Method Summary collapse
-
#column_names ⇒ Object
get a list of column names for a given class.
- #create!(attributes) ⇒ Object
- #find_all(options) ⇒ Object
- #find_first(options) ⇒ Object
- #get(id) ⇒ Object
- #get!(id) ⇒ Object
Class Method Details
.except_classes ⇒ Object
Do not consider these to be part of the class list
11 12 13 |
# File 'lib/orm_adapter/adapters/simply_stored.rb', line 11 def self.except_classes @@except_classes ||= [] end |
.model_classes ⇒ Object
Gets a list of the available models for this adapter
16 17 18 |
# File 'lib/orm_adapter/adapters/simply_stored.rb', line 16 def self.model_classes ObjectSpace.each_object(Class).to_a.select {|klass| klass.ancestors.include? SimplyStored::Couch} end |
Instance Method Details
#column_names ⇒ Object
get a list of column names for a given class
21 22 23 |
# File 'lib/orm_adapter/adapters/simply_stored.rb', line 21 def column_names klass.fields.keys end |
#create!(attributes) ⇒ Object
48 49 50 |
# File 'lib/orm_adapter/adapters/simply_stored.rb', line 48 def create!(attributes) klass.create!(attributes) end |
#find_all(options) ⇒ Object
42 43 44 45 |
# File 'lib/orm_adapter/adapters/simply_stored.rb', line 42 def find_all() conditions, order = extract_conditions_and_order!() klass.where(conditions_to_fields(conditions)).order_by(order) end |
#find_first(options) ⇒ Object
36 37 38 39 |
# File 'lib/orm_adapter/adapters/simply_stored.rb', line 36 def find_first() conditions, order = extract_conditions_and_order!() klass.limit(1).where(conditions_to_fields(conditions)).order_by(order).first end |
#get(id) ⇒ Object
31 32 33 |
# File 'lib/orm_adapter/adapters/simply_stored.rb', line 31 def get(id) klass.where(:_id => wrap_key(id)).first end |
#get!(id) ⇒ Object
26 27 28 |
# File 'lib/orm_adapter/adapters/simply_stored.rb', line 26 def get!(id) klass.find(wrap_key(id)) end |