sam / dm-more

Extras for DataMapper, including bridges to DataObjects::Migrations and Merb::DataMapper

This URL has Read+Write access

Dan Kubb (author)
Tue Jun 24 08:55:58 -0700 2008
commit  47b8a82b187f95dfb4702ebd0b99903fcf2daf44
tree    ea62155c04ac75f2762f0fc35017e816d7a5d72c
parent  e602a514b011d7d510950414b45ce5b9309c4012
dm-more / dm-shorthand
name age message
..
file LICENSE Loading commit data...
file README
file Rakefile
file TODO
directory lib/
directory spec/
dm-shorthand/README
dm-shorthand
============

DataMapper plugin providing shortcut usage of models in multiple repositories.

When using this plugin, every time you define a new model M, a method with the same
name as the model is defined inside the module where you defined M.

=Example

Let's say you have repositories :default, :one and :two.

  class MyModel
    include DataMapper::Resource

    property :a, String
    property :b, String
  end

This will allow you to operate on those repositories like this:

  # create a new instance of MyModel in repository :one
  MyModel(:one).create(:a => "a's value!", :b => "b's value!")

  # fetch the MyModel instance with id == 1 from repository :two
  MyModel(:two)[1]

  # instantiate a new MyModel instance with its default repository
  # set to :default
  m = MyModel.new