mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
remove RackDelegation module
Since all controller instances are required to have a request and response object, RackDelegation is no longer needed (we always have to delegate to the response)
This commit is contained in:
parent
6570ab7af8
commit
d47438745e
14 changed files with 16 additions and 74 deletions
|
@ -30,7 +30,6 @@ module ActionController
|
|||
autoload :Instrumentation
|
||||
autoload :MimeResponds
|
||||
autoload :ParamsWrapper
|
||||
autoload :RackDelegation
|
||||
autoload :Redirecting
|
||||
autoload :Renderers
|
||||
autoload :Rendering
|
||||
|
|
|
@ -115,7 +115,6 @@ module ActionController
|
|||
Rendering,
|
||||
Renderers::All,
|
||||
ConditionalGet,
|
||||
RackDelegation,
|
||||
BasicImplicitRender,
|
||||
StrongParameters,
|
||||
|
||||
|
|
|
@ -213,7 +213,6 @@ module ActionController
|
|||
Renderers::All,
|
||||
ConditionalGet,
|
||||
EtagWithTemplateDigest,
|
||||
RackDelegation,
|
||||
Caching,
|
||||
MimeResponds,
|
||||
ImplicitRender,
|
||||
|
|
|
@ -45,7 +45,6 @@ module ActionController
|
|||
end
|
||||
end
|
||||
|
||||
include RackDelegation
|
||||
include AbstractController::Callbacks
|
||||
|
||||
include ConfigMethods
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'active_support/core_ext/array/extract_options'
|
||||
require 'action_dispatch/middleware/stack'
|
||||
require 'active_support/deprecation'
|
||||
require 'action_dispatch/http/request'
|
||||
require 'action_dispatch/http/response'
|
||||
|
||||
module ActionController
|
||||
# Extend ActionDispatch middleware stack to make it aware of options
|
||||
|
@ -138,20 +140,22 @@ module ActionController
|
|||
end
|
||||
end
|
||||
|
||||
def self.build_with_env(env = {}) #:nodoc:
|
||||
new.tap { |c|
|
||||
c.set_request! ActionDispatch::Request.new(env)
|
||||
c.set_response! make_response!(c.request)
|
||||
}
|
||||
end
|
||||
|
||||
# Delegates to the class' <tt>controller_name</tt>
|
||||
def controller_name
|
||||
self.class.controller_name
|
||||
end
|
||||
|
||||
# The details below can be overridden to support a specific
|
||||
# Request and Response object. The default ActionController::Base
|
||||
# implementation includes RackDelegation, which makes a request
|
||||
# and response object available. You might wish to control the
|
||||
# environment and response manually for performance reasons.
|
||||
|
||||
attr_internal :response, :request
|
||||
delegate :session, :to => "@_request"
|
||||
delegate :headers, :to => "@_response"
|
||||
delegate :headers, :status=, :location=, :content_type=,
|
||||
:status, :location, :content_type, :to => "@_response"
|
||||
|
||||
def initialize
|
||||
@_request = nil
|
||||
|
@ -168,40 +172,13 @@ module ActionController
|
|||
@_params = val
|
||||
end
|
||||
|
||||
# Basic implementations for content_type=, location=, and headers are
|
||||
# provided to reduce the dependency on the RackDelegation module
|
||||
# in Renderer and Redirector.
|
||||
|
||||
def content_type=(type)
|
||||
response.content_type = type
|
||||
end
|
||||
|
||||
def content_type
|
||||
response.content_type
|
||||
end
|
||||
|
||||
def location
|
||||
headers["Location"]
|
||||
end
|
||||
|
||||
def location=(url)
|
||||
headers["Location"] = url
|
||||
end
|
||||
alias :response_code :status # :nodoc:
|
||||
|
||||
# Basic url_for that can be overridden for more robust functionality
|
||||
def url_for(string)
|
||||
string
|
||||
end
|
||||
|
||||
def status
|
||||
response.status
|
||||
end
|
||||
alias :response_code :status # :nodoc:
|
||||
|
||||
def status=(status)
|
||||
response.status = Rack::Utils.status_code(status)
|
||||
end
|
||||
|
||||
def response_body=(body)
|
||||
body = [body] unless body.nil? || body.respond_to?(:each)
|
||||
response.body = body
|
||||
|
@ -233,6 +210,10 @@ module ActionController
|
|||
response.to_a
|
||||
end
|
||||
|
||||
def reset_session
|
||||
@_request.reset_session
|
||||
end
|
||||
|
||||
class_attribute :middleware_stack
|
||||
self.middleware_stack = ActionController::MiddlewareStack.new
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ module ActionController
|
|||
module ConditionalGet
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
include RackDelegation
|
||||
include Head
|
||||
|
||||
included do
|
||||
|
|
|
@ -2,8 +2,6 @@ module ActionController #:nodoc:
|
|||
module Cookies
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
include RackDelegation
|
||||
|
||||
included do
|
||||
helper_method :cookies
|
||||
end
|
||||
|
|
|
@ -11,7 +11,6 @@ module ActionController
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
include AbstractController::Logger
|
||||
include ActionController::RackDelegation
|
||||
|
||||
attr_internal :view_runtime
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
require 'action_dispatch/http/request'
|
||||
require 'action_dispatch/http/response'
|
||||
|
||||
module ActionController
|
||||
module RackDelegation
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
delegate :headers, :status=, :location=, :content_type=,
|
||||
:status, :location, :content_type, :response_code, :to => "@_response"
|
||||
|
||||
module ClassMethods
|
||||
def build_with_env(env = {}) #:nodoc:
|
||||
new.tap { |c| c.set_request! ActionDispatch::Request.new(env) }
|
||||
end
|
||||
end
|
||||
|
||||
def reset_session
|
||||
@_request.reset_session
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,7 +11,6 @@ module ActionController
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
include AbstractController::Logger
|
||||
include ActionController::RackDelegation
|
||||
include ActionController::UrlFor
|
||||
|
||||
# Redirects the browser to the target specified in +options+. This parameter can be any one of:
|
||||
|
|
|
@ -2,8 +2,6 @@ module ActionController
|
|||
module Testing
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
include RackDelegation
|
||||
|
||||
# TODO : Rewrite tests using controller.headers= to use Rack env
|
||||
def headers=(new_headers)
|
||||
@_response ||= ActionDispatch::Response.new
|
||||
|
|
|
@ -2,8 +2,6 @@ require "abstract_unit"
|
|||
|
||||
module BareMetalTest
|
||||
class BareController < ActionController::Metal
|
||||
include ActionController::RackDelegation
|
||||
|
||||
def index
|
||||
self.response_body = "Hello world"
|
||||
end
|
||||
|
|
|
@ -234,8 +234,6 @@ class MetalTestController < ActionController::Metal
|
|||
include AbstractController::Rendering
|
||||
include ActionView::Rendering
|
||||
include ActionController::Rendering
|
||||
include ActionController::RackDelegation
|
||||
|
||||
|
||||
def accessing_logger_in_template
|
||||
render :inline => "<%= logger.class %>"
|
||||
|
|
|
@ -363,9 +363,6 @@ controller modules by default:
|
|||
- `ActionController::Renderers::All`: Support for `render :json` and friends.
|
||||
- `ActionController::ConditionalGet`: Support for `stale?`.
|
||||
- `ActionController::ForceSSL`: Support for `force_ssl`.
|
||||
- `ActionController::RackDelegation`: Support for the `request` and `response`
|
||||
methods returning `ActionDispatch::Request` and `ActionDispatch::Response`
|
||||
objects.
|
||||
- `ActionController::DataStreaming`: Support for `send_file` and `send_data`.
|
||||
- `AbstractController::Callbacks`: Support for `before_action` and friends.
|
||||
- `ActionController::Instrumentation`: Support for the instrumentation
|
||||
|
|
Loading…
Reference in a new issue