Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4317

Show
Ignore:
Timestamp:
04/30/06 20:17:06 (2 years ago)
Author:
rick
Message:

Add Integration Session methods for PUT and DELETE requests [Rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/integration.rb

    r4312 r4317  
    144144      # should be a hash.  The keys will automatically be upcased, with the  
    145145      # prefix 'HTTP_' added if needed. 
     146      # 
     147      # You can also perform POST, PUT, DELETE, and HEAD requests with #post,  
     148      # #put, #delete, and #head. 
    146149      def get(path, parameters=nil, headers=nil) 
    147150        process :get, path, parameters, headers 
    148151      end 
    149152 
    150       # Performs a POST request with the given parameters. The parameters may 
    151       # be +nil+, a Hash, or a string that is appropriately encoded 
    152       # (application/x-www-form-urlencoded or multipart/form-data).  The headers 
    153       # should be a hash.  The keys will automatically be upcased, with the  
    154       # prefix 'HTTP_' added if needed. 
    155       def post(path, parameters=nil, headers=nil) 
    156         process :post, path, parameters, headers 
     153      # keep the docs for #get 
     154      %w( post put delete head ).each do |method| 
     155        class_eval <<-EOV, __FILE__, __LINE__ 
     156          def #{method}(path, parameters=nil, headers=nil) 
     157            process :#{method}, path, parameters, headers 
     158          end 
     159        EOV 
    157160      end 
    158161