1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Port all remaining self.protected_instance_variables to class methods"

This reverts commit 7de994fa21.
This commit is contained in:
Łukasz Strzałkowski 2013-09-02 23:05:42 +02:00
parent 90ea6f928c
commit 40fcb9e822
5 changed files with 19 additions and 21 deletions

View file

@ -373,6 +373,8 @@ module ActionMailer
include AbstractController::AssetPaths
include AbstractController::Callbacks
self.protected_instance_variables = [:@_action_has_layout]
helper ActionMailer::MailHelper
private_class_method :new #:nodoc:
@ -385,10 +387,6 @@ module ActionMailer
parts_order: [ "text/plain", "text/enriched", "text/html" ]
}.freeze
def self.default_protected_instance_vars
super.concat [:@_action_has_layout]
end
class << self
# Register one or more Observers which will be notified when mail is delivered.
def register_observers(*observers)

View file

@ -114,11 +114,6 @@ module AbstractController
end
end
# Define some internal variables that should not be propagated to the view.
def self.default_protected_instance_vars
[]
end
abstract!
# Calls the action going through the entire action dispatch stack.

View file

@ -13,8 +13,13 @@ module AbstractController
module Rendering
extend ActiveSupport::Concern
def self.default_protected_instance_vars
super.concat [:@_action_name, :@_response_body, :@_formats, :@_prefixes, :@_config]
included do
class_attribute :protected_instance_variables
self.protected_instance_variables = []
end
def default_protected_instance_vars
[:@_action_name, :@_response_body, :@_formats, :@_prefixes, :@_config]
end
# Raw rendering of a template to a string.
@ -52,9 +57,10 @@ module AbstractController
# :api: public
def view_assigns
hash = {}
(instance_variables - self.class.default_protected_instance_vars).each do |name|
hash[name[1..-1]] = instance_variable_get(name)
end
variables = instance_variables
variables -= protected_instance_variables
variables -= default_protected_instance_vars
variables.each { |name| hash[name[1..-1]] = instance_variable_get(name) }
hash
end

View file

@ -261,12 +261,11 @@ module ActionController
include mod
end
def self.default_protected_instance_vars
super.concat [
:@_status, :@_headers, :@_params, :@_env, :@_response, :@_request,
:@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout
]
end
# Define some internal variables that should not be propagated to the view.
self.protected_instance_variables = [
:@_status, :@_headers, :@_params, :@_env, :@_response, :@_request,
:@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout
]
ActiveSupport.run_load_hooks(:action_controller, self)
end

View file

@ -17,7 +17,7 @@ class ActionController::Base
def assigns(key = nil)
assigns = {}
instance_variables.each do |ivar|
next if ActionController::Base.default_protected_instance_vars.include?(ivar)
next if ActionController::Base.protected_instance_variables.include?(ivar)
assigns[ivar[1..-1]] = instance_variable_get(ivar)
end