From def8f101b86fbafb2d70316f9218bba9cb276754 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 22 May 2007 09:38:54 +0000 Subject: Strip junk whitespace from [6806]. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6807 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/resources.rb | 104 +++++++++++++------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index 767d4c400a..84094dd09c 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -1,15 +1,15 @@ module ActionController # == Overview # - # ActionController::Resources are a way of defining RESTful resources. A RESTful resource, in basic terms, + # ActionController::Resources are a way of defining RESTful resources. A RESTful resource, in basic terms, # is something that can be pointed at and it will respond with a representation of the data requested. - # In real terms this could mean a user with a browser requests an HTML page, or that a desktop application - # requests XML data. + # In real terms this could mean a user with a browser requests an HTML page, or that a desktop application + # requests XML data. # - # RESTful design is based on the assumption that there are four generic verbs that a user of an + # RESTful design is based on the assumption that there are four generic verbs that a user of an # application can request from a resource (the noun). # - # Resources can be requested using four basic HTTP verbs (GET, POST, PUT, DELETE), the method used + # Resources can be requested using four basic HTTP verbs (GET, POST, PUT, DELETE), the method used # denotes the type of action that should take place. # # === The Different Methods and their Usage @@ -32,8 +32,8 @@ module ActionController # # A DELETE request on a single Post resource is asking for it to be deleted # DELETE /posts # with => { :id => 1 } # - # By using the REST convention, users of our application can assume certain things about how the data - # is requested and how it is returned. Rails simplifies the routing part of RESTful design by + # By using the REST convention, users of our application can assume certain things about how the data + # is requested and how it is returned. Rails simplifies the routing part of RESTful design by # supplying you with methods to create them in your routes.rb file. # # Read more about REST at http://en.wikipedia.org/wiki/Representational_State_Transfer @@ -47,41 +47,41 @@ module ActionController def initialize(entities, options) @plural = entities @singular = options[:singular] || plural.to_s.singularize - + @options = options - + arrange_actions add_default_actions set_prefixes end - + def controller @controller ||= "#{options[:namespace]}#{(options[:controller] || plural).to_s}" end - + def requirements(with_id = false) @requirements ||= @options[:requirements] || {} @id_requirement ||= { :id => @requirements.delete(:id) || /[^#{Routing::SEPARATORS.join}]+/ } - + with_id ? @requirements.merge(@id_requirement) : @requirements end - + def path @path ||= "#{path_prefix}/#{plural}" end - + def new_path @new_path ||= "#{path}/new" end - + def member_path @member_path ||= "#{path}/:id" end - + def nesting_path_prefix @nesting_path_prefix ||= "#{path}/:#{singular}_id" end - + def nesting_name_prefix "#{name_prefix}#{singular}_" end @@ -93,7 +93,7 @@ module ActionController @member_methods = arrange_actions_by_methods(options.delete(:member)) @new_methods = arrange_actions_by_methods(options.delete(:new)) end - + def add_default_actions add_default_action(member_methods, :get, :edit) add_default_action(new_methods, :get, :new) @@ -110,7 +110,7 @@ module ActionController flipped_hash end end - + def add_default_action(collection, method, action) (collection[method] ||= []).unshift(action) end @@ -132,67 +132,67 @@ module ActionController # Creates named routes for implementing verb-oriented controllers. This is # useful for implementing REST API's, where a single resource has different # behavior based on the HTTP verb (method) used to access it. - # + # # Example: # - # map.resources :messages + # map.resources :messages # # class MessagesController < ActionController::Base # # GET messages_url # def index # # return all messages # end - # + # # # GET new_message_url # def new # # return an HTML form for describing a new message # end - # + # # # POST messages_url # def create # # create a new message # end - # + # # # GET message_url(:id => 1) # def show # # find and return a specific message # end - # + # # # GET edit_message_url(:id => 1) # def edit # # return an HTML form for editing a specific message # end - # + # # # PUT message_url(:id => 1) # def update # # find and update a specific message # end - # + # # # DELETE message_url(:id => 1) # def destroy # # delete a specific message # end # end - # + # # The #resources method sets HTTP method restrictions on the routes it generates. For example, making an - # HTTP POST on new_message_url will raise a RoutingError exception. The default route in + # HTTP POST on new_message_url will raise a RoutingError exception. The default route in # config/routes.rb overrides this and allows invalid HTTP methods for resource routes. - # + # # Along with the routes themselves, #resources generates named routes for use in # controllers and views. map.resources :messages produces the following named routes and helpers: - # + # # Named Route Helpers - # messages messages_url, hash_for_messages_url, + # messages messages_url, hash_for_messages_url, # messages_path, hash_for_messages_path - # message message_url(id), hash_for_message_url(id), + # message message_url(id), hash_for_message_url(id), # message_path(id), hash_for_message_path(id) - # new_message new_message_url, hash_for_new_message_url, + # new_message new_message_url, hash_for_new_message_url, # new_message_path, hash_for_new_message_path # edit_message edit_message_url(id), hash_for_edit_message_url(id), # edit_message_path(id), hash_for_edit_message_path(id) # # You can use these helpers instead of #url_for or methods that take #url_for parameters: - # + # # redirect_to :controller => 'messages', :action => 'index' # # becomes # redirect_to messages_url @@ -205,11 +205,11 @@ module ActionController # form tags. The form helpers make this a little easier. For an update form with a @message object: # # <%= form_tag message_path(@message), :method => :put %> - # - # or - # + # + # or + # # <% form_for :message, @message, :url => message_path(@message), :html => {:method => :put} do |f| %> - # + # # The #resources method accepts various options, too, to customize the resulting # routes: # * :controller -- specify the controller name for the routes. @@ -227,7 +227,7 @@ module ActionController # end # # The comment resources work the same, but must now include a value for :article_id. - # + # # comments_url(@article) # comment_url(@article, @comment) # @@ -249,27 +249,27 @@ module ActionController # If map.resources is called with multiple resources, they all get the same options applied. # # Examples: - # + # # map.resources :messages, :path_prefix => "/thread/:thread_id" # # --> GET /thread/7/messages/1 - # + # # map.resources :messages, :collection => { :rss => :get } # # --> GET /messages/rss (maps to the #rss action) # # also adds a named route called "rss_messages" - # + # # map.resources :messages, :member => { :mark => :post } # # --> POST /messages/1/mark (maps to the #mark action) # # also adds a named route called "mark_message" - # + # # map.resources :messages, :new => { :preview => :post } # # --> POST /messages/new/preview (maps to the #preview action) # # also adds a named route called "preview_new_message" - # + # # map.resources :messages, :new => { :new => :any, :preview => :post } # # --> POST /messages/new/preview (maps to the #preview action) # # also adds a named route called "preview_new_message" # # --> /messages/new can be invoked via any request method - # + # # map.resources :messages, :controller => "categories", # :path_prefix => "/category/:category_id", # :name_prefix => "category_" @@ -280,10 +280,10 @@ module ActionController entities.each { |entity| map_resource(entity, options.dup, &block) } end - # Creates named routes for implementing verb-oriented controllers for a singleton resource. + # Creates named routes for implementing verb-oriented controllers for a singleton resource. # A singleton resource is global to the current user visiting the application, such as a user's # /account profile. - # + # # See map.resources for general conventions. These are the main differences: # - a singular name is given to map.resource. The default controller name is taken from the singular name. # - To specify a custom plural name, use the :plural option. There is no :singular option @@ -292,7 +292,7 @@ module ActionController # # Example: # - # map.resource :account + # map.resource :account # # class AccountController < ActionController::Base # # POST account_url @@ -328,9 +328,9 @@ module ActionController # # Along with the routes themselves, #resource generates named routes for use in # controllers and views. map.resource :account produces the following named routes and helpers: - # + # # Named Route Helpers - # account account_url, hash_for_account_url, + # account account_url, hash_for_account_url, # account_path, hash_for_account_path # edit_account edit_account_url, hash_for_edit_account_url, # edit_account_path, hash_for_edit_account_path @@ -353,7 +353,7 @@ module ActionController if block_given? with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, &block) - end + end end end -- cgit v1.2.3