Sha256: 8acf2cb0deedde75bab07937b6e7b800ab50b500341319a2a749ca4a057e7108

Contents?: true

Size: 716 Bytes

Versions: 7

Compression:

Stored size: 716 Bytes

Contents

# Use this together with the Rack::MethodOverride middleware for best
# behaviour.
#
# See spec/contrib/rest.rb for usage.

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'}

  Rewrite['REST dispatch'] = lambda{|path, request|
    if suffix = Ramaze.options[:rest_rewrite][request.request_method]
      "#{path}/#{suffix}".squeeze('/')
    else
      path
    end
    # return '/'
  }
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ramaze-2011.01.30 lib/ramaze/contrib/rest.rb
ramaze-2011.01 lib/ramaze/contrib/rest.rb
ramaze-2010.06.18 lib/ramaze/contrib/rest.rb
ramaze-2010.04.04 lib/ramaze/contrib/rest.rb
ramaze-2010.04 lib/ramaze/contrib/rest.rb
ramaze-2010.03 lib/ramaze/contrib/rest.rb
ramaze-2010.01 lib/ramaze/contrib/rest.rb