Skip to content
Browse files

Removed ramaze/rest. It was extremely crippled and didn't work proper…

…ly anyway.

I tried coming up with a nice helper to replace this but I eventually decided
not to include it since there are multiple ways of doing it.
  • Loading branch information...
1 parent 558afb7 commit 14d277ddae9720168c18be036e435a255c53408a @YorickPeterse YorickPeterse committed Aug 9, 2011
Showing with 0 additions and 64 deletions.
  1. +0 −36 lib/ramaze/rest.rb
  2. +0 −28 spec/ramaze/rest.rb
View
36 lib/ramaze/rest.rb
@@ -1,36 +0,0 @@
-##
-# The code in this file adds an extra option and a route to Ramaze that allows
-# REST like HTTP requests. For example, when this file is loaded a GET request
-# to a controller will be mapped to the "show" method while a POST request will
-# be mapped to "create". In order to use this extension you have to load it
-# manually:
-#
-# require 'ramaze/rest'
-#
-# From this point on you can customize the route as following:
-#
-# Ramaze.options.rest_rewrite['GET'] = 'another_method'
-#
-module Ramaze
- # Don't use one option per method, we don't want to turn request_method into a
- # symbol, together with MethodOverride this could lead to a memory leak.
- options.o(
- 'REST rewrite mapping',
- :rest_rewrite,
- {
- 'GET' => 'show',
- 'POST' => 'create',
- 'PUT' => 'update',
- 'DELETE' => 'destroy'
- }
- )
-
- # Re-write the URLs according to the settings set above
- Rewrite['REST dispatch'] = lambda do |path, request|
- if suffix = Ramaze.options[:rest_rewrite][request.request_method]
- "#{path}/#{suffix}".squeeze('/')
- else
- path
- end
- end
-end # Ramaze
View
28 spec/ramaze/rest.rb
@@ -1,28 +0,0 @@
-require File.expand_path('../../../spec/helper', __FILE__)
-require 'ramaze/rest'
-
-class Posts < Ramaze::Controller
- map '/'
-
- def show; 'Showing' end
- def create; 'Creating' end
- def update; 'Updating' end
- def destroy; 'Destroying' end
-
- def show_other; 'Showing other' end
-end
-
-describe 'Contrib REST rewrite' do
- behaves_like :rack_test
-
- it('rewrites GET to show'){ get('/').body.should == 'Showing' }
- it('rewrites POST to create'){ post('/').body.should == 'Creating' }
- it('rewrites PUT to update'){ put('/').body.should == 'Updating' }
- it('rewrites DELETE to destroy'){ delete('/').body.should == 'Destroying' }
-
- it 'is configurable' do
- Ramaze.options.rest_rewrite['GET'] = 'show_other'
-
- get('/').body.should == 'Showing other'
- end
-end

0 comments on commit 14d277d

Please sign in to comment.
Something went wrong with that request. Please try again.