Cleaning up if defined?(ActionController::Http) blocks from the pre new base era.

This commit is contained in:
Yehuda Katz + Carl Lerche 2009-06-17 16:23:11 -07:00
parent 8fdf3d7890
commit 55ee0ba7f5
7 changed files with 44 additions and 92 deletions

@ -28,13 +28,7 @@ module ActionController #:nodoc:
module Flash
extend ActiveSupport::Concern
# TODO : Remove the defined? check when new base is the main base
include Session if defined?(ActionController::Http)
included do
# TODO : Remove the defined? check when new base is the main base
include InstanceMethods
end
include Session
class FlashNow #:nodoc:
def initialize(flash)
@ -141,33 +135,30 @@ def use(key = nil, used = true)
end
end
module InstanceMethods #:nodoc:
protected
def process_action(method_name)
super
if defined? @_flash
@_flash.store(session)
remove_instance_variable(:@_flash)
end
end
def reset_session
super
remove_instance_variable(:@_flash) if defined?(@_flash)
end
protected
def process_action(method_name)
super
if defined? @_flash
@_flash.store(session)
remove_instance_variable(:@_flash)
end
end
protected
# Access the contents of the flash. Use <tt>flash["notice"]</tt> to
# read a notice you put there or <tt>flash["notice"] = "hello"</tt>
# to put a new one.
def flash #:doc:
if !defined?(@_flash)
@_flash = session["flash"] || FlashHash.new
@_flash.sweep
end
def reset_session
super
remove_instance_variable(:@_flash) if defined?(@_flash)
end
@_flash
# Access the contents of the flash. Use <tt>flash["notice"]</tt> to
# read a notice you put there or <tt>flash["notice"] = "hello"</tt>
# to put a new one.
def flash #:doc:
if !defined?(@_flash)
@_flash = session["flash"] || FlashHash.new
@_flash.sweep
end
@_flash
end
end
end

@ -4,10 +4,7 @@ module ActionController #:nodoc:
module Streaming
extend ActiveSupport::Concern
# TODO : Remove the defined? check when new base is the main base
if defined?(ActionController::Http)
include ActionController::Renderer
end
include ActionController::Renderer
DEFAULT_SEND_FILE_OPTIONS = {
:type => 'application/octet-stream'.freeze,

@ -2,7 +2,6 @@ module ActionController #:nodoc:
module Verification #:nodoc:
extend ActiveSupport::Concern
# TODO : Remove the defined? check when new base is the main base
include AbstractController::Callbacks, Session, Flash, Renderer
# This module provides a class-level method for specifying that certain

@ -84,19 +84,10 @@ def initialize(options, &block)
@options = options
end
# TODO: Remove once New Base is merged
if defined?(ActionController::Http)
def filter(controller)
should_continue = before(controller)
yield if should_continue
after(controller)
end
else
def filter(controller, action)
should_continue = before(controller)
action.call if should_continue
after(controller)
end
def filter(controller)
should_continue = before(controller)
yield if should_continue
after(controller)
end
def before(controller)

@ -230,39 +230,24 @@ def include(*args)
def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil, formats = nil)#:nodoc:
@formats = formats || [:html]
@assigns = assigns_for_first_render
@assigns_added = nil
@controller = controller
@helpers = ProxyModule.new(self)
self.view_paths = view_paths
@_first_render = nil
@_current_render = nil
end
attr_internal :template
attr_reader :view_paths
def view_paths=(paths)
@view_paths = self.class.process_view_paths(paths)
end
# Access the current template being rendered.
# Returns a ActionView::Template object.
def template
@_current_render
end
def template=(template) #:nodoc:
@_first_render ||= template
@_current_render = template
end
def with_template(current_template)
last_template, self.template = template, current_template
old_formats, self.formats = formats, [current_template.mime_type.to_sym] + Mime::SET.symbols
last_formats, self.formats = formats, [current_template.mime_type.to_sym] + Mime::SET.symbols
yield
ensure
self.template = last_template
self.formats = old_formats
self.template, self.formats = last_template, last_formats
end
def punctuate_body!(part)
@ -273,30 +258,21 @@ def punctuate_body!(part)
# Evaluates the local assigns and controller ivars, pushes them to the view.
def _evaluate_assigns_and_ivars #:nodoc:
unless @assigns_added
@assigns.each { |key, value| instance_variable_set("@#{key}", value) }
_copy_ivars_from_controller
@assigns_added = true
return if @assigns_added
@assigns.each { |key, value| instance_variable_set("@#{key}", value) }
_copy_ivars_from_controller
@assigns_added = true
end
private
def _copy_ivars_from_controller #:nodoc:
if @controller
variables = @controller.instance_variable_names
variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables)
variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) }
end
end
private
def _copy_ivars_from_controller #:nodoc:
if @controller
variables = @controller.instance_variable_names
variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables)
variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) }
end
end
def _set_controller_content_type(content_type) #:nodoc:
# TODO: Remove this method when new base is switched
unless defined?(ActionController::Http)
if controller.respond_to?(:response)
controller.response.content_type ||= content_type
end
end
end
end
end

@ -64,7 +64,6 @@ def _render_content_with_layout(content, layout, locals)
def _render_template(template, local_assigns = {})
with_template(template) do
_evaluate_assigns_and_ivars
_set_controller_content_type(template.mime_type) if template.respond_to?(:mime_type)
template.render(self, local_assigns) do |*names|
if !instance_variable_defined?(:"@content_for_#{names.first}") &&

@ -8,8 +8,7 @@ class Builder < TemplateHandler
self.default_format = Mime::XML
def compile(template)
"_set_controller_content_type(Mime::XML);" +
"xml = ::Builder::XmlMarkup.new(:indent => 2);" +
"xml = ::Builder::XmlMarkup.new(:indent => 2);" +
"self.output_buffer = xml.target!;" +
template.source +
";xml.target!;"