AC::Head now doesn't have an unfulfilled Rendering dependency, and instead works just fine standalone (which means that ConditionalGet also doesn't have a Rendering dependency)

This commit is contained in:
Yehuda Katz
2009-12-20 18:50:47 -08:00
parent eeda059818
commit 17f66473bc
8 changed files with 24 additions and 14 deletions

View File

@@ -5,6 +5,7 @@ module AbstractController
class Base
attr_internal :response_body
attr_internal :action_name
attr_internal :formats
class << self
attr_reader :abstract

View File

@@ -16,7 +16,6 @@ module AbstractController
include AbstractController::Logger
included do
attr_internal :formats
extlib_inheritable_accessor :_view_paths
self._view_paths ||= ActionView::PathSet.new
end

View File

@@ -89,7 +89,7 @@ module ActionController
end
if options[:status]
options[:status] = _interpret_status(options[:status])
options[:status] = ActionDispatch::StatusCodes[options[:status]]
end
options[:update] = blk if block_given?

View File

@@ -68,6 +68,10 @@ module ActionController
headers["Location"] = url
end
def status=(status)
@_status = ActionDispatch::StatusCodes[status]
end
# :api: private
def dispatch(name, env)
@_env = env
@@ -92,6 +96,7 @@ module ActionController
def initialize(controller, action)
@controller, @action = controller, action
@_formats = [Mime::HTML]
end
def call(env)

View File

@@ -1,5 +1,7 @@
module ActionController
module Head
include UrlFor
# Return a response that has no content (merely headers). The options
# argument is interpreted to be a hash of header names and values.
# This allows you to easily return a response that consists only of
@@ -21,7 +23,10 @@ module ActionController
headers[key.to_s.dasherize.split(/-/).map { |v| v.capitalize }.join("-")] = value.to_s
end
render :nothing => true, :status => status, :location => location
self.status = status
self.location = url_for(location) if location
self.content_type = Mime[formats.first]
self.response_body = " "
end
end
end

View File

@@ -62,9 +62,9 @@ module ActionController
private
def _extract_redirect_to_status(options, response_status)
status = if options.is_a?(Hash) && options.key?(:status)
_interpret_status(options.delete(:status))
ActionDispatch::StatusCodes[options.delete(:status)]
elsif response_status.key?(:status)
_interpret_status(response_status[:status])
ActionDispatch::StatusCodes[response_status[:status]]
else
302
end
@@ -86,13 +86,5 @@ module ActionController
url_for(options)
end.gsub(/[\r\n]/, '')
end
def _interpret_status(status)
if status.is_a?(Symbol)
(ActionDispatch::StatusCodes::SYMBOL_TO_STATUS_CODE[status] || 500)
else
status.to_i
end
end
end
end

View File

@@ -60,7 +60,7 @@ module ActionDispatch # :nodoc:
end
def status=(status)
@status = status.to_i
@status = ActionDispatch::StatusCodes[status]
end
# The response code of the request

View File

@@ -14,6 +14,14 @@ module ActionDispatch
510 => "Not Extended"
}).freeze
def self.[](status)
if status.is_a?(Symbol)
SYMBOL_TO_STATUS_CODE[status] || 500
else
status.to_i
end
end
# Provides a symbol-to-fixnum lookup for converting a symbol (like
# :created or :not_implemented) into its corresponding HTTP status
# code (like 200 or 501).