Gears Within Gears

Seek simplicity, and distrust it.

Announcing the release of ResourceFull 0.7.1

Posted by Brian Guthrie
16 March 2009 at 03:03AM

ResourceFull integrates with ActionController to provide a comprehensive
RESTful resource modeling and querying framework. It provides parameter
queryability, paging, sorting, separation of controller concerns, multiple
formats (HTML, XML, JSON), CRUD access permissions, and API metadata
surrounding the resource itself. It’s opinionated but is intended to provide
you with as much as possible without limiting your ability to customize its
behavior.

This plugin was extracted from a series of Rails projects intended to serve as the services tier of a series of loosely-coupled applications built in a style reminiscent of the RADAR architecture.

ResourceFull lives on Github at http://github.com/bguthrie/resource_full/.

GOALS

The major distinguishing features of ResourceFull are:

  • Queryability: the ability to designate certain parameters as queryable,
    and map them to columns and SQL queries in the underlying model.
    These queries chain together multiple named or unnamed scopes and can be
    used either for a SQL SELECT or SELECT COUNT.
    This functionality may be moved into a separate plugin in the future.
  • Pagination and orderability: it automatically responds to requests for
    limit, offset, order_by, and order_dir.
  • Implementation: Default implementations for HTML, XML, and JSON controller requests.
  • API documentation: ResourceFull-enabled Rails apps are able to provide automatic
    documentation of the resources they expose, up to a point. (This is enabled
    in large part by the queryability functionality and other resource-level
    descriptors.) It’s my hope that this can eventually be consumed by a Rails
    resource registrar that acts as the single source of record for multiple REST
    engines within an organization.

EXAMPLE

This allows for the following:
  /users/bguthrie.xml
  /users?name=Guthrie
  /users?email_address=gmail
  /users.xml?city=Chicago&name=Brian,Paul,Alicia&order_by=city&order_dir=asc
  /users.xml?limit=10&offset=30
  /users/bguthrie/addresses

API DOCUMENTATION

To enable ResourceFull to document your resources at /resources.xml and /resources/:name/routes.xml,
add map.api to your routes.rb file.