From 9caaf2650397a128001babe5271bd31641c561fd Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Thu, 19 Mar 2020 15:59:46 -0400 Subject: [PATCH] Use array subtraction to compute variables of interest in view_assigns --- actionpack/lib/abstract_controller/rendering.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index f20d143567..61bcfc5a2f 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -56,19 +56,15 @@ module AbstractController Mime[:text] end - DEFAULT_PROTECTED_INSTANCE_VARIABLES = Set.new %i( - @_action_name @_response_body @_formats @_prefixes - ) + DEFAULT_PROTECTED_INSTANCE_VARIABLES = %i(@_action_name @_response_body @_formats @_prefixes) # This method should return a hash with assigns. # You can overwrite this configuration per controller. def view_assigns - protected_vars = _protected_ivars + variables = instance_variables - _protected_ivars - instance_variables.each_with_object({}) do |name, hash| - unless protected_vars.include?(name) - hash[name.slice(1, name.length)] = instance_variable_get(name) - end + variables.each_with_object({}) do |name, hash| + hash[name.slice(1, name.length)] = instance_variable_get(name) end end