Class: DataMapper::Adapters::DataObjectsAdapter

Class | DataMapper::Adapters::DataObjectsAdapter
In: | lib/dm-core/adapters/data_objects_adapter.rb
Parent: | AbstractAdapter

DataObjectsAdapter is the base class for all adapers for relational databases. If you want to add support for a new RDBMS, it makes sense to make your adapter class inherit from this class.

By inheriting from DataObjectsAdapter, you get a copy of all the standard sub-modules (Quoting, Coersion and Queries) in your own Adapter. You can extend and overwrite these copies without affecting the originals.

### Methods

close_connection create delete execute new normalized_uri open_connection query read update

### Included Modules

SQL

### Public Class methods

new(name, uri_or_options)

TODO: document @api public

### Public Instance methods

create(resources)

For each model instance in resources, issues an SQL INSERT (or equivalent) statement to create a new record in the data store for the instance

Note that this method does not update identity map. A plugin needs to use adapter directly, it is up to plugin developer to keep identity map up to date.

@param [Enumerable(Resource)] resources

      The list of resources (model instances) to create

@return [Integer]

      The number of records that were actually saved into the database

@api semipublic

delete(collection)

Constructs and executes DELETE statement for given query

@param [Collection] collection

      collection of records to be deleted

@return [Integer]

      the number of records deleted

@api semipublic

execute(statement, *bind_values)

Database-specific method TODO: document @api public

query(statement, *bind_values)

TODO: document @api public

read(query)

Constructs and executes SELECT query, then instantiates one or many object from result set.

@param [Query] query

      composition of the query to perform

@return [Array]

      result set of the query

@api semipublic

update(attributes, collection)

Constructs and executes UPDATE statement for given attributes and a query

@param [Hash(Property => Object)] attributes

      hash of attribute values to set, keyed by Property

@param [Collection] collection

      collection of records to be updated

@return [Integer]

      the number of records updated

@api semipublic

### Protected Instance methods

close_connection(connection)

Takes connection and closes it

@api semipublic

normalized_uri()

TODO: document @api private

open_connection()

Instantiates new connection object

@api semipublic

[Validate]