Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Map DataMapper models and methods to RESTful Rack routes.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/rack/mapper
spec
.document
.gitignore
.rspec
.yardopts
ChangeLog.md
LICENSE.txt
README.md
Rakefile
gemspec.yml
rack-mapper.gemspec

README.md

rack-mapper

Description

A Rack middleware which allows mapping DataMapper models and their methods to RESTful Rack routes.

Features

Examples

require 'dm-core'

class Post

  include DataMapper::Resource

  property :id, Serial

  property :title, String

  property :body, Text

  belongs_to :user

  def summary(n)
    self.body.split(/s+/,n).take(n).join(' ') + ' ...'
  end

end

class User

  include DataMapper::Resource

  property :id, Serial

  property :name, String

  has n, :posts

end

require 'rack/mapper'

use Rack::Mapper do
  map User
  map Post do
    get :summary, :params => [:n]
  end
end
# GET    /users
# GET    /users/1
# GET    /posts
# GET    /posts/1
# GET    /posts/1/summary?n=100

Requirements

Install

$ gem install rack-mapper

Copyright

Copyright (c) 2011 Hal Brodigan

See {file:LICENSE.txt} for details.

Something went wrong with that request. Please try again.