diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-02 14:29:36 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-02 14:29:36 -0700 |
commit | e3b695331d95022f9b41faf131f8e98cdf4f6985 (patch) | |
tree | e21ed9bc1230900d401e1412ae86f24625942ea0 /actionpack/lib/abstract_controller | |
parent | 90ea6f928ce0f0efef3109045a74469c4a3e3f99 (diff) | |
parent | 544d0fad3d76bd3077225c6afcb562197f240cb0 (diff) | |
download | rails-e3b695331d95022f9b41faf131f8e98cdf4f6985.tar.gz rails-e3b695331d95022f9b41faf131f8e98cdf4f6985.tar.bz2 rails-e3b695331d95022f9b41faf131f8e98cdf4f6985.zip |
Merge pull request #12110 from strzalek/revert-default-protected-instance-vars
Revert default protected instance vars
Diffstat (limited to 'actionpack/lib/abstract_controller')
-rw-r--r-- | actionpack/lib/abstract_controller/base.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/rendering.rb | 17 |
2 files changed, 12 insertions, 10 deletions
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb index a84ed17bd4..af5de815bb 100644 --- a/actionpack/lib/abstract_controller/base.rb +++ b/actionpack/lib/abstract_controller/base.rb @@ -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. diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 41f19fba78..a3c45bacb7 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -13,8 +13,9 @@ 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 # Raw rendering of a template to a string. @@ -47,14 +48,20 @@ module AbstractController def rendered_format end + DEFAULT_PROTECTED_INSTANCE_VARIABLES = %w( + @_action_name @_response_body @_formats @_prefixes @_config + @_view_context_class @_view_renderer @_lookup_context + ) + # This method should return a hash with assigns. # You can overwrite this configuration per controller. # :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_VARIABLES + variables.each { |name| hash[name[1..-1]] = instance_variable_get(name) } hash end |