Code Spike for a DataMapper2 Mapper
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 1462 commits behind solnic:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
README.md

README.md

The Mapper for DataMapper 2.0 (code spike)

This is a code spike to implement a prototype of a mapper for Veritas which can work with PORO or Virtus objects.

See spec/integration for examples of what already works.

More information coming soon...

Sample code

Here's an idea of how a mapper API could look like:

  class User
    attr_reader :id, :name

    def initialize(attributes)
      @id, @name = attributes.values_at(:id, :name)
    end

    class Mapper < DataMapper::VeritasMapper
      map :id, :type => Integer
      map :name, :to => :username, :type => String

      model User
      name 'users'
    end
  end

  # find all users
  User::Mapper.find

  # find users with name 'John'
  User::Mapper.find(:name => 'John')