/ˌeɪ.piˈaɪ/
– The JSON API Framework 
Opinionated JSON-API stack to get the job done.
This library brings some of the best* Ruby JSON API libraries together, provides the glue to make things easy to work with out-of-the-box, and even easier to modify to your own liking.
* in our humble opinion
Usage
More detailed installation instructions will follow. But for now, here's an example:
gem 'eipiai'
gem 'roar'
gem 'sequel'
gem 'sqlite3'
bundle install
require 'eipiai'
require 'roar/decorator'
require 'roar/json/hal'
require 'sequel'
require 'sqlite3'
DB = Sequel.sqlite
DB.create_table(:items) do
primary_key :id
String :uid
end
class Item < Sequel::Model
end
class ItemRepresenter < Roar::Decorator
include Roar::JSON::HAL
property :uid
def path
"/item/#{represented.uid}"
end
end
class ItemsRepresenter < Roar::Decorator
include Roar::JSON::HAL
collection :items, getter: proc { Item.all }, decorator: ItemRepresenter
def path
'/items'
end
end
class ItemResource < Webmachine::Resource
include Eipiai::Resource
end
class ItemsResource < Webmachine::Resource
include Eipiai::Resource
end
App = Webmachine::Application.new do |app|
app.routes do
add ['items'], ItemsResource
add ['item', :item_uid], ItemResource
end
end
App.run
bundle exec ruby app.rb &
curl -XPOST -d'{"uid":"awesome"}' -HContent-Type:application/json localhost:8080/items
curl localhost:8080/item/awesome
# {"uid":"awesome"}