From ff9ca2ca1e1646e22ff43ec1a5844a0b733d5ba3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 9 Sep 2007 23:12:57 +0000 Subject: [PATCH] Random hits from the style nazi git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7438 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_controller/assertions.rb | 2 +- actionpack/lib/action_controller/base.rb | 40 +++++++++++++++---- .../lib/action_controller/components.rb | 2 +- actionpack/lib/action_controller/cookies.rb | 2 +- actionpack/lib/action_controller/filters.rb | 2 +- actionpack/lib/action_controller/helpers.rb | 2 +- .../action_controller/http_authentication.rb | 2 +- .../lib/action_controller/integration.rb | 15 ++++--- actionpack/lib/action_controller/layout.rb | 2 +- .../lib/action_controller/mime_responds.rb | 2 +- actionpack/lib/action_controller/mime_type.rb | 2 +- .../action_controller/polymorphic_routes.rb | 2 +- actionpack/lib/action_controller/request.rb | 2 +- actionpack/lib/action_controller/rescue.rb | 2 +- actionpack/lib/action_controller/resources.rb | 2 +- actionpack/lib/action_controller/routing.rb | 3 +- .../session/active_record_store.rb | 2 +- 17 files changed, 54 insertions(+), 32 deletions(-) diff --git a/actionpack/lib/action_controller/assertions.rb b/actionpack/lib/action_controller/assertions.rb index 941201b335..fe16b97bd3 100644 --- a/actionpack/lib/action_controller/assertions.rb +++ b/actionpack/lib/action_controller/assertions.rb @@ -67,4 +67,4 @@ class TestCase #:nodoc: include ActionController::Assertions end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index a636f8b246..4d896bc262 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -11,12 +11,16 @@ module ActionController #:nodoc: class ActionControllerError < StandardError #:nodoc: end + class SessionRestoreError < ActionControllerError #:nodoc: end + class MissingTemplate < ActionControllerError #:nodoc: end + class RenderError < ActionControllerError #:nodoc: end + class RoutingError < ActionControllerError #:nodoc: attr_reader :failures def initialize(message, failures=[]) @@ -24,6 +28,7 @@ def initialize(message, failures=[]) @failures = failures end end + class MethodNotAllowed < ActionControllerError #:nodoc: attr_reader :allowed_methods @@ -40,16 +45,22 @@ def handle_response!(response) response.headers['Allow'] ||= allowed_methods_header end end + class NotImplemented < MethodNotAllowed #:nodoc: end + class UnknownController < ActionControllerError #:nodoc: end + class UnknownAction < ActionControllerError #:nodoc: end + class MissingFile < ActionControllerError #:nodoc: end + class RenderError < ActionControllerError #:nodoc: end + class SessionOverflowError < ActionControllerError #:nodoc: DEFAULT_MESSAGE = 'Your session data is larger than the data column in which it is to be stored. You must increase the size of your data column if you intend to store large data.' @@ -57,6 +68,7 @@ def initialize(message = nil) super(message || DEFAULT_MESSAGE) end end + class DoubleRenderError < ActionControllerError #:nodoc: DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and only once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\". Finally, note that to cause a before filter to halt execution of the rest of the filter chain, the filter must return false, explicitly, so \"render(...) and return false\"." @@ -64,6 +76,7 @@ def initialize(message = nil) super(message || DEFAULT_MESSAGE) end end + class RedirectBackError < ActionControllerError #:nodoc: DEFAULT_MESSAGE = 'No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env["HTTP_REFERER"].' @@ -72,6 +85,7 @@ def initialize(message = nil) end end + # Action Controllers are the core of a web request in Rails. They are made up of one or more actions that are executed # on request and then either render a template or redirect to another action. An action is defined as a public method # on the controller, which will automatically be made accessible to the web-server through Rails Routes. @@ -371,7 +385,10 @@ def controller_path # By default, all methods defined in ActionController::Base and included modules are hidden. # More methods can be hidden using hide_actions. def hidden_actions - write_inheritable_attribute(:hidden_actions, ActionController::Base.public_instance_methods) unless read_inheritable_attribute(:hidden_actions) + unless read_inheritable_attribute(:hidden_actions) + write_inheritable_attribute(:hidden_actions, ActionController::Base.public_instance_methods) + end + read_inheritable_attribute(:hidden_actions) end @@ -817,12 +834,17 @@ def render(options = nil, &block) #:doc: elsif partial = options[:partial] partial = default_template_name if partial == true add_variables_to_assigns + if collection = options[:collection] - render_for_text(@template.send(:render_partial_collection, partial, collection, options[:spacer_template], options[:locals]), - options[:status]) + render_for_text( + @template.send(:render_partial_collection, partial, collection, + options[:spacer_template], options[:locals]), options[:status] + ) else - render_for_text(@template.send(:render_partial, partial, ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals]), - options[:status]) + render_for_text( + @template.send(:render_partial, partial, + ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals]), options[:status] + ) end elsif options[:update] @@ -1012,8 +1034,8 @@ def reset_session #:doc: response.session = @_session end - private + private def render_for_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc: add_variables_to_assigns assert_existence_of_template_file(template_path) if use_full_path @@ -1035,7 +1057,9 @@ def render_for_text(text = nil, status = nil, append_response = false) #:nodoc: end def initialize_template_class(response) - raise "You must assign a template class through ActionController.template_class= before processing a request" unless @@template_class + unless @@template_class + raise "You must assign a template class through ActionController.template_class= before processing a request" + end response.template = ActionView::Base.new(view_paths, {}, self) response.template.extend self.class.master_helper_module @@ -1207,4 +1231,4 @@ def process_cleanup close_session end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb index dc3032219b..5ef6e2afba 100644 --- a/actionpack/lib/action_controller/components.rb +++ b/actionpack/lib/action_controller/components.rb @@ -162,4 +162,4 @@ def process_cleanup_with_components end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/cookies.rb b/actionpack/lib/action_controller/cookies.rb index 0f01873064..66db80d8ef 100644 --- a/actionpack/lib/action_controller/cookies.rb +++ b/actionpack/lib/action_controller/cookies.rb @@ -72,4 +72,4 @@ def set_cookie(options) #:doc: @controller.response.headers["cookie"] << cookie end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/filters.rb b/actionpack/lib/action_controller/filters.rb index ec3f5096e3..03b65074f4 100644 --- a/actionpack/lib/action_controller/filters.rb +++ b/actionpack/lib/action_controller/filters.rb @@ -754,4 +754,4 @@ def halt_filter_chain(filter, reason) end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb index b42bc8a555..251d32775f 100644 --- a/actionpack/lib/action_controller/helpers.rb +++ b/actionpack/lib/action_controller/helpers.rb @@ -200,4 +200,4 @@ def all_application_helpers end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/http_authentication.rb b/actionpack/lib/action_controller/http_authentication.rb index 78f41eb503..4e77103de2 100644 --- a/actionpack/lib/action_controller/http_authentication.rb +++ b/actionpack/lib/action_controller/http_authentication.rb @@ -126,4 +126,4 @@ def authentication_request(controller, realm) end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb index 2806485a98..bfacfb26d1 100644 --- a/actionpack/lib/action_controller/integration.rb +++ b/actionpack/lib/action_controller/integration.rb @@ -152,27 +152,27 @@ def redirect? # # You can also perform POST, PUT, DELETE, and HEAD requests with #post, # #put, #delete, and #head. - def get(path, parameters=nil, headers=nil) + def get(path, parameters = nil, headers = nil) process :get, path, parameters, headers end # Performs a POST request with the given parameters. See get() for more details. - def post(path, parameters=nil, headers=nil) + def post(path, parameters = nil, headers = nil) process :post, path, parameters, headers end # Performs a PUT request with the given parameters. See get() for more details. - def put(path, parameters=nil, headers=nil) + def put(path, parameters = nil, headers = nil) process :put, path, parameters, headers end # Performs a DELETE request with the given parameters. See get() for more details. - def delete(path, parameters=nil, headers=nil) + def delete(path, parameters = nil, headers = nil) process :delete, path, parameters, headers end # Performs a HEAD request with the given parameters. See get() for more details. - def head(path, parameters=nil, headers=nil) + def head(path, parameters = nil, headers = nil) process :head, path, parameters, headers end @@ -220,7 +220,7 @@ def interpret_uri(path) end # Performs the actual request. - def process(method, path, parameters=nil, headers=nil) + def process(method, path, parameters = nil, headers = nil) data = requestify(parameters) path = interpret_uri(path) if path =~ %r{://} path = "/#{path}" unless path[0] == ?/ @@ -333,7 +333,6 @@ def requestify(parameters, prefix=nil) "#{CGI.escape(prefix)}=#{CGI.escape(parameters.to_s)}" end end - end # A module used to extend ActionController::Base, so that integration tests @@ -553,4 +552,4 @@ def method_missing(sym, *args, &block) end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index 5655a9bd0b..0c1513c9a1 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -306,4 +306,4 @@ def layout_directory?(layout_name) end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb index 1f28f7ad13..65eb7c896d 100644 --- a/actionpack/lib/action_controller/mime_responds.rb +++ b/actionpack/lib/action_controller/mime_responds.rb @@ -176,4 +176,4 @@ def respond end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb index 44a60487b2..7c7faefa46 100644 --- a/actionpack/lib/action_controller/mime_type.rb +++ b/actionpack/lib/action_controller/mime_type.rb @@ -154,4 +154,4 @@ def method_missing(method, *args) end end -require 'action_controller/mime_types' +require 'action_controller/mime_types' \ No newline at end of file diff --git a/actionpack/lib/action_controller/polymorphic_routes.rb b/actionpack/lib/action_controller/polymorphic_routes.rb index 0e826d4ee7..2e048dfceb 100644 --- a/actionpack/lib/action_controller/polymorphic_routes.rb +++ b/actionpack/lib/action_controller/polymorphic_routes.rb @@ -85,4 +85,4 @@ def extract_namespace(record_or_hash_or_array) end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index bab265f77e..ceedcfec4f 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -660,4 +660,4 @@ def type_conflict!(klass, value) raise TypeError, "Conflicting types for parameter containers. Expected an instance of #{klass} but found an instance of #{value.class}. This can be caused by colliding Array and Hash parameters like qs[]=value&qs[key]=value." end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index 8eb6379fcf..8cffc90d33 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -157,4 +157,4 @@ def clean_backtrace(exception) end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index 384f5f30d7..e909a65eab 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -514,4 +514,4 @@ def action_options_for(action, resource, method = nil) end end -ActionController::Routing::RouteSet::Mapper.send :include, ActionController::Resources +ActionController::Routing::RouteSet::Mapper.send :include, ActionController::Resources \ No newline at end of file diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index d20c17c30e..bbf6eefd8f 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -1445,5 +1445,4 @@ def extract_request_environment(request) Routes = RouteSet.new end -end - +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/session/active_record_store.rb b/actionpack/lib/action_controller/session/active_record_store.rb index c268cc1937..14747c5052 100644 --- a/actionpack/lib/action_controller/session/active_record_store.rb +++ b/actionpack/lib/action_controller/session/active_record_store.rb @@ -333,4 +333,4 @@ def logger end end end -end +end \ No newline at end of file -- GitLab