2009-04-27 21:21:26 -04:00
|
|
|
module ActionController
|
2009-12-02 23:01:01 -05:00
|
|
|
module Compatibility
|
2009-05-28 12:35:36 -04:00
|
|
|
extend ActiveSupport::Concern
|
2009-05-21 05:50:34 -04:00
|
|
|
|
|
|
|
class ::ActionController::ActionControllerError < StandardError #:nodoc:
|
|
|
|
end
|
|
|
|
|
2010-03-02 20:20:13 -05:00
|
|
|
module ClassMethods
|
|
|
|
end
|
|
|
|
|
2009-05-01 20:27:44 -04:00
|
|
|
# Temporary hax
|
2009-05-11 20:07:05 -04:00
|
|
|
included do
|
2009-05-11 15:45:26 -04:00
|
|
|
::ActionController::UnknownAction = ::AbstractController::ActionNotFound
|
|
|
|
::ActionController::DoubleRenderError = ::AbstractController::DoubleRenderError
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2010-03-02 20:20:13 -05:00
|
|
|
# ROUTES TODO: This should be handled by a middleware and route generation
|
|
|
|
# should be able to handle SCRIPT_NAME
|
|
|
|
self.config.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
|
2009-05-28 10:49:02 -04:00
|
|
|
|
Got overhead down from 127 to 85. All tests pass:
* Tentatively replaced HeaderHash with SimpleHeaderHash, which does not preserve
case but does handle converting Arrays to Strings in to_hash. This requires
further discussion.
* Moved default_charset to ActionDispatch::Response to avoid having to hop over
to ActionController. Ideally, this would be a constant on AD::Response, but
some tests expect to be able to change it dynamically and I didn't want to change
them yet.
* Completely override #initialize from Rack::Response. Previously, it was creating
a HeaderHash, and then we were creating an entirely new one. There is no way to
call super without incurring the overhead of creating a HeaderHash.
* Override #write from Rack::Response. Its implementation tracks Content-Length,
and doing so adds additional overhead that could be mooted if other middleware
changes the body. It is more efficiently done at the top-level server.
* Change sending_file to an instance_variable instead of header inspection. In
general, if a state is important, it should be set as a property of the response
not reconstructed later.
* Set the Etag to @body instead of .body. AS::Cache.expand_cache_key handles
Arrays fine, and it's more efficient to let it handle the body parts, since
it is not forced to create a joined String.
* If we detect the default cache control case, just set it, rather than setting
the constituent parts and then running the normal (expensive) code to generate
the string.
2009-08-10 11:40:41 -04:00
|
|
|
class << self
|
|
|
|
delegate :default_charset=, :to => "ActionDispatch::Response"
|
|
|
|
end
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-12 19:21:34 -04:00
|
|
|
# cattr_reader :protected_instance_variables
|
|
|
|
cattr_accessor :protected_instance_variables
|
2009-10-29 00:37:29 -04:00
|
|
|
self.protected_instance_variables = %w(@assigns @performed_redirect @performed_render
|
|
|
|
@variables_added @request_origin @url
|
|
|
|
@parent_controller @action_name
|
|
|
|
@before_filter_chain_aborted @_headers @_params
|
2010-01-15 15:44:27 -05:00
|
|
|
@_response)
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2010-03-04 15:21:49 -05:00
|
|
|
def rescue_action(env)
|
|
|
|
raise env["action_dispatch.rescue.exception"]
|
2010-03-03 12:32:27 -05:00
|
|
|
end
|
|
|
|
|
2009-05-15 20:49:11 -04:00
|
|
|
self.page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
|
2009-05-11 17:48:58 -04:00
|
|
|
end
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-19 21:08:04 -04:00
|
|
|
# For old tests
|
|
|
|
def initialize_template_class(*) end
|
|
|
|
def assign_shortcuts(*) end
|
|
|
|
|
2009-05-20 18:33:08 -04:00
|
|
|
def template
|
2009-08-06 18:45:40 -04:00
|
|
|
@template ||= view_context
|
2009-05-26 15:06:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def process_action(*)
|
|
|
|
template
|
|
|
|
super
|
2009-05-20 18:33:08 -04:00
|
|
|
end
|
|
|
|
|
2010-03-08 05:32:01 -05:00
|
|
|
def _normalize_options(options)
|
|
|
|
# TODO Deprecate this. Rails 2.x allowed to give a template as action.
|
|
|
|
if options[:action] && options[:action].to_s.include?(?/)
|
|
|
|
options[:template] = options.delete(:action)
|
2009-04-27 21:21:26 -04:00
|
|
|
end
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-08-10 18:49:33 -04:00
|
|
|
options[:text] = nil if options.delete(:nothing) == true
|
|
|
|
options[:text] = " " if options.key?(:text) && options[:text].nil?
|
2010-03-08 05:32:01 -05:00
|
|
|
super
|
|
|
|
end
|
2009-05-11 15:04:43 -04:00
|
|
|
|
2010-03-08 05:32:01 -05:00
|
|
|
def render_to_body(options)
|
|
|
|
options[:template].sub!(/^\//, '') if options.key?(:template)
|
2009-08-10 18:49:33 -04:00
|
|
|
super || " "
|
2009-04-27 21:21:26 -04:00
|
|
|
end
|
2009-05-15 18:57:12 -04:00
|
|
|
|
|
|
|
def _handle_method_missing
|
|
|
|
method_missing(@_action_name.to_sym)
|
|
|
|
end
|
|
|
|
|
|
|
|
def method_for_action(action_name)
|
|
|
|
super || (respond_to?(:method_missing) && "_handle_method_missing")
|
2009-05-28 10:49:02 -04:00
|
|
|
end
|
|
|
|
|
2009-05-20 20:55:25 -04:00
|
|
|
def performed?
|
|
|
|
response_body
|
|
|
|
end
|
2009-04-27 21:21:26 -04:00
|
|
|
end
|
2009-05-21 23:22:18 -04:00
|
|
|
end
|