diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-07 21:58:31 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-07 21:58:31 +0000 |
commit | c3cdd3b6595ad59129d7652f6f3274f26509a4dc (patch) | |
tree | 399bbb4e1227bad6e18ea6f543e075ec09a1feb0 /actionpack/lib/action_controller | |
parent | c0657a9084825f7ca7b0277e5f07a7ae26b8a126 (diff) | |
download | rails-c3cdd3b6595ad59129d7652f6f3274f26509a4dc.tar.gz rails-c3cdd3b6595ad59129d7652f6f3274f26509a4dc.tar.bz2 rails-c3cdd3b6595ad59129d7652f6f3274f26509a4dc.zip |
Deprecation: check whether instance variables have been monkeyed with before assigning them to deprecation proxies. Raises a RuntimeError if so.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4717 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 8823076fcc..2125637192 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -400,7 +400,6 @@ module ActionController #:nodoc: def process(request, response, method = :perform_action, *arguments) #:nodoc: initialize_template_class(response) assign_shortcuts(request, response) - assign_deprecated_shortcuts(request, response) initialize_current_url assign_names forget_variables_added_to_assigns @@ -942,6 +941,8 @@ module ActionController #:nodoc: @assigns = @response.template.assigns @headers = @response.headers + + assign_deprecated_shortcuts(request, response) end @@ -950,8 +951,15 @@ module ActionController #:nodoc: # Gone after 1.2. def assign_deprecated_shortcuts(request, response) - DEPRECATED_INSTANCE_VARIABLES.each do |var| - instance_variable_set "@#{var}", ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, var) + DEPRECATED_INSTANCE_VARIABLES.each do |method| + var = "@#{method}" + if instance_variables.include?(var) + value = instance_variable_get(var) + unless ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy === value + raise "Deprecating #{var}, but it's already set to #{value.inspect}! Use the #{method}= writer method instead of setting #{var} directly." + end + end + instance_variable_set var, ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, method) end end @@ -1011,7 +1019,7 @@ module ActionController #:nodoc: end def add_instance_variables_to_assigns - @@protected_variables_cache ||= protected_instance_variables.inject({}) { |h, k| h[k] = true; h } + @@protected_variables_cache ||= Set.new(protected_instance_variables) instance_variables.each do |var| next if @@protected_variables_cache.include?(var) @assigns[var[1..-1]] = instance_variable_get(var) |