gizmo
Removing the crud from developing an API to support CRUD, in the name of Gizmo.
Installation
The preferred method for installing Gizmo is with bundler. Simply add Gizmo to your Gemfile
:
gem "gizmo"
Usage
class PostsController < ApplicationController
include Gizmo
# for a simple HTML request
def index
gizmo_response = find_all Post
@posts = gizmo_response.data
end
# for a JSON request
def index
render find_all(Post.order_by([[:updated_at, :desc]])).to_hash
end
def show
render find(Post, params[:id]).to_hash
end
def create
render make(Post, params[:post]).to_hash
end
def update
render modify(CmsSupport::Post, params[:id], params[:post]).to_hash
end
def destroy
render delete(CmsSupport::Post, params[:id]).to_hash
end
end
TODO
- look for TODO's
- abtract persistence layer to suport Mongoid, ActiveRecord, etc
- error handling :)
- The gizmo more or less expects to be included into a Rails controller.