Class | OrmAdapter::Base |
In: |
lib/orm_adapter/base.rb
|
Parent: | Object |
klass | [R] |
Your ORM adapter needs to inherit from this Base class and its adapter will be registered. To create an adapter you should create an inner constant "OrmAdapter" e.g. ActiveRecord::Base::OrmAdapter
@see orm_adapters/active_record @see orm_adapters/datamapper @see orm_adapters/mongoid
Find all models, optionally matching conditions, and specifying order @see OrmAdapter::Base#find_first for how to specify order and conditions
Find the first instance, optionally matching conditions, and specifying order
You can call with just conditions, providing a hash
User.to_adapter.find_first :name => "Fred", :age => 23
Or you can specify :order, and :conditions as keys
User.to_adapter.find_first :conditions => {:name => "Fred", :age => 23} User.to_adapter.find_first :order => [:age, :desc] User.to_adapter.find_first :order => :name, :conditions => {:age => 18}
When specifying :order, it may be
Get an instance by id of the model. Returns nil if a model is not found. This should comply with ActiveModel#to_key API, i.e.:
User.to_adapter.get(@user.to_key) == @user
Get an instance by id of the model. Raises an error if a model is not found. This should comply with ActiveModel#to_key API, i.e.:
User.to_adapter.get!(@user.to_key) == @user
given an options hash, with optional :conditions and :order keys, returns conditions and normalized order