Class: DataMapper::Repository

Class | DataMapper::Repository
In: | lib/dm-core/repository.rb
Parent: | Object

### Methods

adapter adapters context create default_name delete identity_map inspect new read scope update

### Included Modules

Extlib::Assertions

### Attributes

name | [R] | TODO: document @api semipublic

### Public Class methods

adapters()

Get the list of adapters registered for all Repositories, keyed by repository name.

      TODO: create example

@return [Hash(Symbol => Adapters::AbstractAdapter)]

      the adapters registered for all Repositories

@api private

context()

Get the stack of current repository contexts

      TODO: create example

@return [Array]

      List of Repository contexts for the current Thread

@api private

default_name()

Get the default name of this Repository

      TODO: create example

@return [Symbol]

      the default name of this repository

@api private

new(name)

Initializes a new Repository

      TODO: create example

@param [Symbol] name

      The name of the Repository

@api semipublic

### Public Instance methods

adapter()

Get the adapter for this repository

Lazy loads adapter setup from registered adapters

      TODO: create example

@return [Adapters::AbstractAdapter]

      the adapter for this repository

@raise [RepositoryNotSetupError]

      if there is no adapter registered for a repository named @name

@api semipublic

create(resources)

Create one or more resource instances in this repository.

      TODO: create example

@param [Enumerable(Resource)] resources

      The list of resources (model instances) to create

@return [Integer]

      The number of records that were actually saved into the data-store

@api semipublic

delete(collection)

Delete one or more resource instances

      TODO: create example

@param [Collection] collection

      collection of records to be deleted

@return [Integer]

      the number of records deleted

@api semipublic

identity_map(model)

Get the identity for a particular model within this repository.

If one doesn‘t yet exist, create a new default in-memory IdentityMap for the requested model.

      TODO: create example

@param [Model] model

      Model whose identity map should be returned

@return [IdentityMap]

      The IdentityMap for model in this Repository

@api private

inspect()

Return a human readable representation of the repository

      TODO: create example

@return [String]

      human readable representation of the repository

@api private

read(query)

Retrieve a collection of results of a query

      TODO: create example

@param [Query] query

      composition of the query to perform

@return [Array]

      result set of the query

@api semipublic

scope() {|self| ...}

Executes a block in the scope of this Repository

      TODO: create example

@yieldparam [Repository] repository

      yields self within the block

@yield

      execute block in the scope of this Repository

@api private

update(attributes, collection)

Update the attributes of one or more resource instances

      TODO: create example

@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

[Validate]