Removing the crud from developing an API to support CRUD, in the name of Gizmo.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
tasks
.gitignore
.rvmrc
.travis.yml
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
gizmo.gemspec

README.md

gizmo Build Status

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.