Skip to content
Permalink
Browse files

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)
  • Loading branch information...
tenderlove committed Aug 26, 2015
1 parent 6570ab7 commit d47438745e34d75e03347b54b604b71b7a92c3ac
@@ -30,7 +30,6 @@ module ActionController
autoload :Instrumentation
autoload :MimeResponds
autoload :ParamsWrapper
autoload :RackDelegation
autoload :Redirecting
autoload :Renderers
autoload :Rendering
@@ -115,7 +115,6 @@ def self.without_modules(*modules)
Rendering,
Renderers::All,
ConditionalGet,
RackDelegation,
BasicImplicitRender,
StrongParameters,

@@ -213,7 +213,6 @@ def self.without_modules(*modules)
Renderers::All,
ConditionalGet,
EtagWithTemplateDigest,
RackDelegation,
Caching,
MimeResponds,
ImplicitRender,
@@ -45,7 +45,6 @@ def cache_configured?
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 @@ def self.make_response!(request)
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 @@ def params=(val)
@_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 @@ def to_a #:nodoc:
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 Instrumentation
extend ActiveSupport::Concern

include AbstractController::Logger
include ActionController::RackDelegation

attr_internal :view_runtime

This file was deleted.

@@ -11,7 +11,6 @@ module Redirecting
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 @@

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

1 comment on commit d474387

@robertomiranda

This comment has been minimized.

Copy link
Contributor

commented on d474387 May 23, 2016

question this also applies to Rails 4, should this back-ported to rails-api/rails-api?

Please sign in to comment.
You can’t perform that action at this time.