Sha256: fa9ddaa6a4455b66b4c99647bd8fe7f270f3da3bdb70a023ba9ca85fed20445d
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'dm-core' module DataMapper module Model include OrmAdapter::ToAdapter end module Resource class OrmAdapter < ::OrmAdapter::Base # get a list of column names for a given class def column_names klass.properties.map(&:name) end # @see OrmAdapter::Base#get! def get!(id) klass.get!(id) end # @see OrmAdapter::Base#get def get(id) klass.get(id) end # @see OrmAdapter::Base#find_first def find_first(options = {}) conditions, order = extract_conditions_and_order!(options) klass.first :conditions => conditions, :order => order_clause(order) end # @see OrmAdapter::Base#find_all def find_all(options = {}) conditions, order = extract_conditions_and_order!(options) klass.all :conditions => conditions, :order => order_clause(order) end # @see OrmAdapter::Base#create! def create!(attributes = {}) klass.create(attributes) end # @see OrmAdapter::Base#destroy def destroy(object) object.destroy if valid_object?(object) end protected def order_clause(order) order.map {|pair| pair.first.send(pair.last)} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
orm_adapter-0.3.0 | lib/orm_adapter/adapters/data_mapper.rb |