Sha256: bd74f03e38d40e45b4bac4a93b2b76ff78f1d6925045eb45e6935b8dcce73486
Contents?: true
Size: 672 Bytes
Versions: 1
Compression:
Stored size: 672 Bytes
Contents
require 'restfulness' $projects = [] Project = Class.new(HashWithIndifferentAccess) class ProjectResource < Restfulness::Resource def exists? !project.nil? end def get project end def post $projects << Project.new(request.params) end def put project.update(request.params) end def delete $projects.delete(project) end protected def project $projects.find{|p| p[:id] == request.path[:id]} end end class ProjectsResource < Restfulness::Resource def get $projects end end class ExampleApp < Restfulness::Application routes do add 'project', ProjectResource add 'projects', ProjectsResource end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restfulness-0.1.0 | example/app.rb |