mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Port all remaining self.protected_instance_variables to class methods
This commit is contained in:
parent
55c9109b5a
commit
7de994fa21
5 changed files with 21 additions and 19 deletions
|
@ -373,8 +373,6 @@ module ActionMailer
|
||||||
include AbstractController::AssetPaths
|
include AbstractController::AssetPaths
|
||||||
include AbstractController::Callbacks
|
include AbstractController::Callbacks
|
||||||
|
|
||||||
self.protected_instance_variables = [:@_action_has_layout]
|
|
||||||
|
|
||||||
helper ActionMailer::MailHelper
|
helper ActionMailer::MailHelper
|
||||||
|
|
||||||
private_class_method :new #:nodoc:
|
private_class_method :new #:nodoc:
|
||||||
|
@ -387,6 +385,10 @@ module ActionMailer
|
||||||
parts_order: [ "text/plain", "text/enriched", "text/html" ]
|
parts_order: [ "text/plain", "text/enriched", "text/html" ]
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
def self.default_protected_instance_vars
|
||||||
|
super.concat [:@_action_has_layout]
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
# Register one or more Observers which will be notified when mail is delivered.
|
# Register one or more Observers which will be notified when mail is delivered.
|
||||||
def register_observers(*observers)
|
def register_observers(*observers)
|
||||||
|
|
|
@ -114,6 +114,11 @@ module AbstractController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Define some internal variables that should not be propagated to the view.
|
||||||
|
def self.default_protected_instance_vars
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
abstract!
|
abstract!
|
||||||
|
|
||||||
# Calls the action going through the entire action dispatch stack.
|
# Calls the action going through the entire action dispatch stack.
|
||||||
|
|
|
@ -13,13 +13,8 @@ module AbstractController
|
||||||
module Rendering
|
module Rendering
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
def self.default_protected_instance_vars
|
||||||
class_attribute :protected_instance_variables
|
super.concat [:@_action_name, :@_response_body, :@_formats, :@_prefixes, :@_config]
|
||||||
self.protected_instance_variables = []
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_protected_instance_vars
|
|
||||||
[:@_action_name, :@_response_body, :@_formats, :@_prefixes, :@_config]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Raw rendering of a template to a string.
|
# Raw rendering of a template to a string.
|
||||||
|
@ -57,10 +52,9 @@ module AbstractController
|
||||||
# :api: public
|
# :api: public
|
||||||
def view_assigns
|
def view_assigns
|
||||||
hash = {}
|
hash = {}
|
||||||
variables = instance_variables
|
(instance_variables - self.class.default_protected_instance_vars).each do |name|
|
||||||
variables -= protected_instance_variables
|
hash[name[1..-1]] = instance_variable_get(name)
|
||||||
variables -= default_protected_instance_vars
|
end
|
||||||
variables.each { |name| hash[name[1..-1]] = instance_variable_get(name) }
|
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -261,11 +261,12 @@ module ActionController
|
||||||
include mod
|
include mod
|
||||||
end
|
end
|
||||||
|
|
||||||
# Define some internal variables that should not be propagated to the view.
|
def self.default_protected_instance_vars
|
||||||
self.protected_instance_variables = [
|
super.concat [
|
||||||
:@_status, :@_headers, :@_params, :@_env, :@_response, :@_request,
|
:@_status, :@_headers, :@_params, :@_env, :@_response, :@_request,
|
||||||
:@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout
|
:@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout
|
||||||
]
|
]
|
||||||
|
end
|
||||||
|
|
||||||
ActiveSupport.run_load_hooks(:action_controller, self)
|
ActiveSupport.run_load_hooks(:action_controller, self)
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ class ActionController::Base
|
||||||
def assigns(key = nil)
|
def assigns(key = nil)
|
||||||
assigns = {}
|
assigns = {}
|
||||||
instance_variables.each do |ivar|
|
instance_variables.each do |ivar|
|
||||||
next if ActionController::Base.protected_instance_variables.include?(ivar)
|
next if ActionController::Base.default_protected_instance_vars.include?(ivar)
|
||||||
assigns[ivar[1..-1]] = instance_variable_get(ivar)
|
assigns[ivar[1..-1]] = instance_variable_get(ivar)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue