Every repository with this icon (
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Tue Jul 01 06:05:30 -0700 2008 | |
| |
README.rdoc | ||
| |
Rakefile | Tue Dec 23 15:36:42 -0800 2008 | |
| |
init.rb | ||
| |
install.rb | Tue Jul 01 06:01:11 -0700 2008 | |
| |
lib/ | ||
| |
spec/ | ||
| |
uninstall.rb | Tue Jul 01 06:01:11 -0700 2008 |
ResourceFull 0.7.0
DESCRIPTION
ResourceFull is a subclass of ActionController intended to provide a comprehensive resource modeling and querying framework. It allows for abstracted handling of queryable parameters, a separation of controller concerns into multiple submethods, handling of respondable formats, and XML serialization of the actual notion of a resource itself for metadata handling purposes. It’s similar to resource_this, but more opinionated and eventually more comprehensive.
Methods may be easily overwritten in subclasses at any pain point to provide custom behaviors for renders and CRUD behavior.
GOALS
This project, as opposed to other similar resource exposure libraries, have been shaped by the requirements of several Rails app intended to be internal sources of record for APIs and data. The library is currently in production use, but not on any Rails apps that are exposed to the outside internet.
The two 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.
- 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
class UsersController < ResourceFull::Base
identified_by :username, :unless => lambda { |id| id =~ /^[0-9]+$/ }
queryable_with :city, :state, :from => :address
queryable_with :name, :columns => [:first_name, :last_name]
queryable_with :email_address, :fuzzy => true
queryable_with :is_active, :scope => :active
orderable_by :city, :from => :address
responds_to :html
responds_to :xml, :only => [:read, :update]
end
class AddressesController < ResourceFull::Base
nests_within :users
queryable_with :city, :state
end
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 >> UsersController.to_xml => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<resource>\n <parameters type=\"array\"/>..."
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.
LICENSE
(The MIT License)
Copyright © 2008 Brian Guthrie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.








