Skip to content
This repository
Browse code

Revert "Port all remaining self.protected_instance_variables to class…

… methods"

This reverts commit 7de994f.
  • Loading branch information...
commit 40fcb9e82220fe9a7a3b0b3aeee61f92f00942c2 1 parent 90ea6f9
Łukasz Strzałkowski strzalek authored
6 actionmailer/lib/action_mailer/base.rb
@@ -373,6 +373,8 @@ class Base < AbstractController::Base
373 373 include AbstractController::AssetPaths
374 374 include AbstractController::Callbacks
375 375
  376 + self.protected_instance_variables = [:@_action_has_layout]
  377 +
376 378 helper ActionMailer::MailHelper
377 379
378 380 private_class_method :new #:nodoc:
@@ -385,10 +387,6 @@ class Base < AbstractController::Base
385 387 parts_order: [ "text/plain", "text/enriched", "text/html" ]
386 388 }.freeze
387 389
388   - def self.default_protected_instance_vars
389   - super.concat [:@_action_has_layout]
390   - end
391   -
392 390 class << self
393 391 # Register one or more Observers which will be notified when mail is delivered.
394 392 def register_observers(*observers)
5 actionpack/lib/abstract_controller/base.rb
@@ -114,11 +114,6 @@ def method_added(name)
114 114 end
115 115 end
116 116
117   - # Define some internal variables that should not be propagated to the view.
118   - def self.default_protected_instance_vars
119   - []
120   - end
121   -
122 117 abstract!
123 118
124 119 # Calls the action going through the entire action dispatch stack.
16 actionpack/lib/abstract_controller/rendering.rb
@@ -13,8 +13,13 @@ def initialize(message = nil)
13 13 module Rendering
14 14 extend ActiveSupport::Concern
15 15
16   - def self.default_protected_instance_vars
17   - super.concat [:@_action_name, :@_response_body, :@_formats, :@_prefixes, :@_config]
  16 + included do
  17 + class_attribute :protected_instance_variables
  18 + self.protected_instance_variables = []
  19 + end
  20 +
  21 + def default_protected_instance_vars
  22 + [:@_action_name, :@_response_body, :@_formats, :@_prefixes, :@_config]
18 23 end
19 24
20 25 # Raw rendering of a template to a string.
@@ -52,9 +57,10 @@ def rendered_format
52 57 # :api: public
53 58 def view_assigns
54 59 hash = {}
55   - (instance_variables - self.class.default_protected_instance_vars).each do |name|
56   - hash[name[1..-1]] = instance_variable_get(name)
57   - end
  60 + variables = instance_variables
  61 + variables -= protected_instance_variables
  62 + variables -= default_protected_instance_vars
  63 + variables.each { |name| hash[name[1..-1]] = instance_variable_get(name) }
58 64 hash
59 65 end
60 66
11 actionpack/lib/action_controller/base.rb
@@ -261,12 +261,11 @@ def self.without_modules(*modules)
261 261 include mod
262 262 end
263 263
264   - def self.default_protected_instance_vars
265   - super.concat [
266   - :@_status, :@_headers, :@_params, :@_env, :@_response, :@_request,
267   - :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout
268   - ]
269   - end
  264 + # Define some internal variables that should not be propagated to the view.
  265 + self.protected_instance_variables = [
  266 + :@_status, :@_headers, :@_params, :@_env, :@_response, :@_request,
  267 + :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout
  268 + ]
270 269
271 270 ActiveSupport.run_load_hooks(:action_controller, self)
272 271 end
2  actionpack/test/controller/filters_test.rb
@@ -17,7 +17,7 @@ def before_filters
17 17 def assigns(key = nil)
18 18 assigns = {}
19 19 instance_variables.each do |ivar|
20   - next if ActionController::Base.default_protected_instance_vars.include?(ivar)
  20 + next if ActionController::Base.protected_instance_variables.include?(ivar)
21 21 assigns[ivar[1..-1]] = instance_variable_get(ivar)
22 22 end
23 23

0 comments on commit 40fcb9e

Please sign in to comment.
Something went wrong with that request. Please try again.