aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/abstract
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-05-28 09:49:02 -0500
committerJoshua Peek <josh@joshpeek.com>2009-05-28 09:49:02 -0500
commitde203245afd2bbf7f93f3241fcf3a71a88101d47 (patch)
tree3fbae223e10f0e50da6d9fdfc2c70a742c34ac26 /actionpack/lib/action_controller/abstract
parentdd98280e38d640f5724887cf8a715b79f0439d2d (diff)
downloadrails-de203245afd2bbf7f93f3241fcf3a71a88101d47.tar.gz
rails-de203245afd2bbf7f93f3241fcf3a71a88101d47.tar.bz2
rails-de203245afd2bbf7f93f3241fcf3a71a88101d47.zip
Revert "Revert "Whitespace!""
This reverts commit 0cac68d3bed3e6bf8ec2eb994858e4a179046941.
Diffstat (limited to 'actionpack/lib/action_controller/abstract')
-rw-r--r--actionpack/lib/action_controller/abstract/base.rb34
-rw-r--r--actionpack/lib/action_controller/abstract/benchmarker.rb6
-rw-r--r--actionpack/lib/action_controller/abstract/callbacks.rb8
-rw-r--r--actionpack/lib/action_controller/abstract/exceptions.rb4
-rw-r--r--actionpack/lib/action_controller/abstract/helpers.rb9
-rw-r--r--actionpack/lib/action_controller/abstract/layouts.rb25
-rw-r--r--actionpack/lib/action_controller/abstract/logger.rb12
-rw-r--r--actionpack/lib/action_controller/abstract/renderer.rb24
8 files changed, 60 insertions, 62 deletions
diff --git a/actionpack/lib/action_controller/abstract/base.rb b/actionpack/lib/action_controller/abstract/base.rb
index bbd42623d3..87083a4d79 100644
--- a/actionpack/lib/action_controller/abstract/base.rb
+++ b/actionpack/lib/action_controller/abstract/base.rb
@@ -2,28 +2,27 @@ require 'active_support/core_ext/module/attr_internal'
module AbstractController
class Error < StandardError; end
-
+
class DoubleRenderError < Error
DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most 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\"."
def initialize(message = nil)
super(message || DEFAULT_MESSAGE)
end
- end
-
+ end
+
class Base
-
attr_internal :response_body
attr_internal :response_obj
attr_internal :action_name
class << self
- attr_reader :abstract
-
+ attr_reader :abstract
+
def abstract!
@abstract = true
end
-
+
alias_method :abstract?, :abstract
def inherited(klass)
@@ -34,13 +33,13 @@ module AbstractController
def subclasses
@subclasses ||= []
end
-
+
def internal_methods
controller = self
controller = controller.superclass until controller.abstract?
controller.public_instance_methods(true)
end
-
+
def process(action)
new.process(action.to_s)
end
@@ -48,7 +47,7 @@ module AbstractController
def hidden_actions
[]
end
-
+
def action_methods
@action_methods ||=
# All public instance methods of this class, including ancestors
@@ -61,13 +60,13 @@ module AbstractController
hidden_actions
end
end
-
+
abstract!
-
+
def initialize
self.response_obj = {}
end
-
+
def process(action)
@_action_name = action_name = action.to_s
@@ -78,17 +77,16 @@ module AbstractController
process_action(action_name)
self
end
-
+
private
-
def action_methods
self.class.action_methods
end
-
+
def action_method?(action)
action_methods.include?(action)
end
-
+
# It is possible for respond_to?(action_name) to be false and
# respond_to?(:action_missing) to be false if respond_to_action?
# is overridden in a subclass. For instance, ActionController::Base
@@ -114,4 +112,4 @@ module AbstractController
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/abstract/benchmarker.rb b/actionpack/lib/action_controller/abstract/benchmarker.rb
index 9f5889c704..9be06f48fb 100644
--- a/actionpack/lib/action_controller/abstract/benchmarker.rb
+++ b/actionpack/lib/action_controller/abstract/benchmarker.rb
@@ -1,9 +1,9 @@
module AbstractController
module Benchmarker
extend ActiveSupport::DependencyModule
-
+
depends_on Logger
-
+
module ClassMethods
def benchmark(title, log_level = ::Logger::DEBUG, use_silence = true)
if logger && logger.level >= log_level
@@ -25,4 +25,4 @@ module AbstractController
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/abstract/callbacks.rb b/actionpack/lib/action_controller/abstract/callbacks.rb
index 83dd06bf8b..4314235ba9 100644
--- a/actionpack/lib/action_controller/abstract/callbacks.rb
+++ b/actionpack/lib/action_controller/abstract/callbacks.rb
@@ -13,7 +13,7 @@ module AbstractController
super
end
end
-
+
module ClassMethods
def _normalize_callback_options(options)
if only = options[:only]
@@ -21,11 +21,11 @@ module AbstractController
options[:per_key] = {:if => only}
end
if except = options[:except]
- except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
+ except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
options[:per_key] = {:unless => except}
end
end
-
+
[:before, :after, :around].each do |filter|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{filter}_filter(*names, &blk)
@@ -60,4 +60,4 @@ module AbstractController
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/abstract/exceptions.rb b/actionpack/lib/action_controller/abstract/exceptions.rb
index ec4680629b..2f6c55f068 100644
--- a/actionpack/lib/action_controller/abstract/exceptions.rb
+++ b/actionpack/lib/action_controller/abstract/exceptions.rb
@@ -1,3 +1,3 @@
module AbstractController
- class ActionNotFound < StandardError ; end
-end \ No newline at end of file
+ class ActionNotFound < StandardError; end
+end
diff --git a/actionpack/lib/action_controller/abstract/helpers.rb b/actionpack/lib/action_controller/abstract/helpers.rb
index 41decfd0c7..7b1b197e1d 100644
--- a/actionpack/lib/action_controller/abstract/helpers.rb
+++ b/actionpack/lib/action_controller/abstract/helpers.rb
@@ -16,12 +16,12 @@ module AbstractController
av
end
end
-
+
module ClassMethods
def inherited(klass)
klass.master_helper_module = Module.new
klass.master_helper_module.__send__ :include, master_helper_module
-
+
super
end
@@ -57,7 +57,7 @@ module AbstractController
ruby_eval
end
end
-
+
def helper(*args, &block)
args.flatten.each do |arg|
case arg
@@ -68,6 +68,5 @@ module AbstractController
master_helper_module.module_eval(&block) if block_given?
end
end
-
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb
index 3d6810bda9..dd38485271 100644
--- a/actionpack/lib/action_controller/abstract/layouts.rb
+++ b/actionpack/lib/action_controller/abstract/layouts.rb
@@ -17,18 +17,18 @@ module AbstractController
conditions.each {|k, v| conditions[k] = Array(v).map {|a| a.to_s} }
self._layout_conditions = conditions
-
+
@_layout = layout || false # Converts nil to false
_write_layout_method
end
-
+
def _implied_layout_name
name.underscore
end
-
+
# Takes the specified layout and creates a _layout method to be called
# by _default_layout
- #
+ #
# If the specified layout is a:
# String:: return the string
# Symbol:: call the method specified by the symbol
@@ -57,11 +57,12 @@ module AbstractController
end
end
end
-
+
private
-
- def _layout(details) end # This will be overwritten
-
+ # This will be overwritten
+ def _layout(details)
+ end
+
# :api: plugin
# ====
# Override this to mutate the inbound layout name
@@ -69,7 +70,7 @@ module AbstractController
unless [String, FalseClass, NilClass].include?(name.class)
raise ArgumentError, "String, false, or nil expected; you passed #{name.inspect}"
end
-
+
name && view_paths.find_by_parts(name, details, _layout_prefix(name))
end
@@ -77,7 +78,7 @@ module AbstractController
def _layout_prefix(name)
"layouts"
end
-
+
def _default_layout(require_layout = false, details = {:formats => formats})
if require_layout && _action_has_layout? && !_layout(details)
raise ArgumentError,
@@ -87,7 +88,7 @@ module AbstractController
begin
_layout_for_name(_layout(details), details) if _action_has_layout?
rescue NameError => e
- raise NoMethodError,
+ raise NoMethodError,
"You specified #{@_layout.inspect} as the layout, but no such method was found"
end
end
@@ -103,4 +104,4 @@ module AbstractController
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/abstract/logger.rb b/actionpack/lib/action_controller/abstract/logger.rb
index 980ede0bed..ce73888763 100644
--- a/actionpack/lib/action_controller/abstract/logger.rb
+++ b/actionpack/lib/action_controller/abstract/logger.rb
@@ -9,7 +9,7 @@ module AbstractController
def initialize(&blk)
@blk = blk
end
-
+
def to_s
@blk.call
end
@@ -19,10 +19,10 @@ module AbstractController
included do
cattr_accessor :logger
end
-
+
def process(action)
ret = super
-
+
if logger
log = DelayedLog.new do
"\n\nProcessing #{self.class.name}\##{action_name} " \
@@ -32,14 +32,14 @@ module AbstractController
logger.info(log)
end
-
+
ret
end
-
+
def request_origin
# this *needs* to be cached!
# otherwise you'd get different results if calling it more than once
@request_origin ||= "#{request.remote_ip} at #{Time.now.to_s(:db)}"
- end
+ end
end
end
diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb
index 7f7ec78054..374ceb5b74 100644
--- a/actionpack/lib/action_controller/abstract/renderer.rb
+++ b/actionpack/lib/action_controller/abstract/renderer.rb
@@ -15,22 +15,22 @@ module AbstractController
end
def _action_view
- @_action_view ||= ActionView::Base.new(self.class.view_paths, {}, self)
+ @_action_view ||= ActionView::Base.new(self.class.view_paths, {}, self)
end
-
+
def render(*args)
if response_body
raise AbstractController::DoubleRenderError, "OMG"
end
-
+
self.response_body = render_to_body(*args)
end
-
+
# Raw rendering of a template to a Rack-compatible body.
# ====
# @option _prefix<String> The template's path prefix
# @option _layout<String> The relative path to the layout template to use
- #
+ #
# :api: plugin
def render_to_body(options = {})
# TODO: Refactor so we can just use the normal template logic for this
@@ -46,7 +46,7 @@ module AbstractController
# ====
# @option _prefix<String> The template's path prefix
# @option _layout<String> The relative path to the layout template to use
- #
+ #
# :api: plugin
def render_to_string(options = {})
AbstractController::Renderer.body_to_s(render_to_body(options))
@@ -55,8 +55,10 @@ module AbstractController
def _render_template(options)
_action_view._render_template_from_controller(options[:_template], options[:_layout], options, options[:_partial])
end
-
- def view_paths() _view_paths end
+
+ def view_paths()
+ _view_paths
+ end
# Return a string representation of a Rack-compatible response body.
def self.body_to_s(body)
@@ -71,7 +73,6 @@ module AbstractController
end
private
-
def _determine_template(options)
name = (options[:_template_name] || action_name).to_s
@@ -81,11 +82,10 @@ module AbstractController
end
module ClassMethods
-
def append_view_path(path)
self.view_paths << path
end
-
+
def prepend_view_path(path)
self.view_paths.unshift(path)
end
@@ -93,7 +93,7 @@ module AbstractController
def view_paths
self._view_paths
end
-
+
def view_paths=(paths)
self._view_paths = paths.is_a?(ActionView::PathSet) ?
paths : ActionView::Base.process_view_paths(paths)