diff options
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 | 16 |
2 files changed, 10 insertions, 11 deletions
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb index af5de815bb..a84ed17bd4 100644 --- a/actionpack/lib/abstract_controller/base.rb +++ b/actionpack/lib/abstract_controller/base.rb @@ -114,6 +114,11 @@ 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 5a5c47eb3b..41f19fba78 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -13,13 +13,8 @@ module AbstractController module Rendering extend ActiveSupport::Concern - included do - class_attribute :protected_instance_variables - self.protected_instance_variables = [] - end - - def default_protected_instance_vars - [:@_action_name, :@_response_body, :@_formats, :@_prefixes, :@_config] + def self.default_protected_instance_vars + super.concat [:@_action_name, :@_response_body, :@_formats, :@_prefixes, :@_config] end # Raw rendering of a template to a string. @@ -57,10 +52,9 @@ module AbstractController # :api: public def view_assigns hash = {} - variables = instance_variables - variables -= protected_instance_variables - variables -= default_protected_instance_vars - variables.each { |name| hash[name[1..-1]] = instance_variable_get(name) } + (instance_variables - self.class.default_protected_instance_vars).each do |name| + hash[name[1..-1]] = instance_variable_get(name) + end hash end |