Permalink
Browse files

Revert "Revert "Whitespace!""

This reverts commit 0cac68d.
  • Loading branch information...
1 parent dd98280 commit de203245afd2bbf7f93f3241fcf3a71a88101d47 @josh josh committed May 28, 2009
Showing with 270 additions and 264 deletions.
  1. +1 −1 actionpack/lib/action_controller/abstract.rb
  2. +16 −18 actionpack/lib/action_controller/abstract/base.rb
  3. +3 −3 actionpack/lib/action_controller/abstract/benchmarker.rb
  4. +4 −4 actionpack/lib/action_controller/abstract/callbacks.rb
  5. +2 −2 actionpack/lib/action_controller/abstract/exceptions.rb
  6. +4 −5 actionpack/lib/action_controller/abstract/helpers.rb
  7. +13 −12 actionpack/lib/action_controller/abstract/layouts.rb
  8. +6 −6 actionpack/lib/action_controller/abstract/logger.rb
  9. +12 −12 actionpack/lib/action_controller/abstract/renderer.rb
  10. +9 −9 actionpack/lib/action_controller/new_base/base.rb
  11. +18 −16 actionpack/lib/action_controller/new_base/compatibility.rb
  12. +14 −15 actionpack/lib/action_controller/new_base/conditional_get.rb
  13. +24 −25 actionpack/lib/action_controller/new_base/helpers.rb
  14. +26 −20 actionpack/lib/action_controller/new_base/hide_actions.rb
  15. +23 −15 actionpack/lib/action_controller/new_base/http.rb
  16. +18 −20 actionpack/lib/action_controller/new_base/layouts.rb
  17. +7 −8 actionpack/lib/action_controller/new_base/rack_convenience.rb
  18. +2 −2 actionpack/lib/action_controller/new_base/redirector.rb
  19. +8 −8 actionpack/lib/action_controller/new_base/render_options.rb
  20. +42 −43 actionpack/lib/action_controller/new_base/renderer.rb
  21. +14 −15 actionpack/lib/action_controller/new_base/rescuable.rb
  22. +1 −2 actionpack/lib/action_controller/new_base/testing.rb
  23. +3 −3 actionpack/lib/action_controller/new_base/url_for.rb
@@ -11,4 +11,4 @@ module AbstractController
autoload :Renderer, "action_controller/abstract/renderer"
# === Exceptions
autoload :ActionNotFound, "action_controller/abstract/exceptions"
-end
+end
@@ -2,28 +2,27 @@
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,21 +33,21 @@ def inherited(klass)
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
def hidden_actions
[]
end
-
+
def action_methods
@action_methods ||=
# All public instance methods of this class, including ancestors
@@ -61,13 +60,13 @@ def action_methods
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 @@ def process(action)
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 @@ def method_for_action(action_name)
end
end
end
-end
+end
@@ -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 @@ def silence
end
end
end
-end
+end
@@ -13,19 +13,19 @@ def process_action(method_name)
super
end
end
-
+
module ClassMethods
def _normalize_callback_options(options)
if only = options[:only]
only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
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 @@ def skip_#{filter}_filter(*names, &blk)
end
end
end
-end
+end
@@ -1,3 +1,3 @@
module AbstractController
- class ActionNotFound < StandardError ; end
-end
+ class ActionNotFound < StandardError; end
+end
@@ -16,12 +16,12 @@ def _action_view
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 @@ def #{meth}(*args, &blk)
ruby_eval
end
end
-
+
def helper(*args, &block)
args.flatten.each do |arg|
case arg
@@ -68,6 +68,5 @@ def helper(*args, &block)
master_helper_module.module_eval(&block) if block_given?
end
end
-
end
-end
+end
@@ -17,18 +17,18 @@ def layout(layout, conditions = {})
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,27 +57,28 @@ def _layout(details)
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
def _layout_for_name(name, details = {:formats => formats})
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
# TODO: Decide if this is the best hook point for the feature
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 @@ def _default_layout(require_layout = false, details = {:formats => formats})
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 @@ def _action_has_layout?
end
end
end
-end
+end
@@ -9,7 +9,7 @@ class DelayedLog
def initialize(&blk)
@blk = blk
end
-
+
def to_s
@blk.call
end
@@ -19,10 +19,10 @@ def to_s
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 @@ def process(action)
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
@@ -15,22 +15,22 @@ module Renderer
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 @@ def render_to_body(options = {})
# ====
# @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 @@ def render_to_string(options = {})
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 @@ def self.body_to_s(body)
end
private
-
def _determine_template(options)
name = (options[:_template_name] || action_name).to_s
@@ -81,19 +82,18 @@ def _determine_template(options)
end
module ClassMethods
-
def append_view_path(path)
self.view_paths << path
end
-
+
def prepend_view_path(path)
self.view_paths.unshift(path)
end
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)
Oops, something went wrong.

1 comment on commit de20324

Nice! Now I'm waiting for:

Revert "Revert "Revert "Whitespace!"""

http://www.youtube.com/watch?v=1tqxzWdKKu8

Please sign in to comment.