diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-09-08 19:57:32 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-09-08 19:57:32 -0700 |
commit | dc0411fad78bfc92fe92dc88bbad726eb4d1a883 (patch) | |
tree | 7533c6ecd1b711a3162cc4264228d6279b8c4b84 /actionpack/lib/action_view/renderable_partial.rb | |
parent | 8b4461c1a405e52e22ee05dd8b46168402d02968 (diff) | |
download | rails-dc0411fad78bfc92fe92dc88bbad726eb4d1a883.tar.gz rails-dc0411fad78bfc92fe92dc88bbad726eb4d1a883.tar.bz2 rails-dc0411fad78bfc92fe92dc88bbad726eb4d1a883.zip |
Check for uninitialized instance variables
Diffstat (limited to 'actionpack/lib/action_view/renderable_partial.rb')
-rw-r--r-- | actionpack/lib/action_view/renderable_partial.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/renderable_partial.rb b/actionpack/lib/action_view/renderable_partial.rb index 123a9aebbc..d92ff1b8d3 100644 --- a/actionpack/lib/action_view/renderable_partial.rb +++ b/actionpack/lib/action_view/renderable_partial.rb @@ -1,8 +1,7 @@ module ActionView - module RenderablePartial - # NOTE: The template that this mixin is beening include into is frozen - # So you can not set or modify any instance variables - + # NOTE: The template that this mixin is being included into is frozen + # so you cannot set or modify any instance variables + module RenderablePartial #:nodoc: extend ActiveSupport::Memoizable def variable_name @@ -30,10 +29,13 @@ module ActionView local_assigns[variable_name] if view.respond_to?(:controller) - object ||= ActiveSupport::Deprecation::DeprecatedObjectProxy.new( - view.controller.instance_variable_get("@#{variable_name}"), - "@#{variable_name} will no longer be implicitly assigned to #{variable_name}" - ) + ivar = :"@#{variable_name}" + object ||= + if view.controller.instance_variable_defined?(ivar) + ActiveSupport::Deprecation::DeprecatedObjectProxy.new( + view.controller.instance_variable_get(ivar), + "#{ivar} will no longer be implicitly assigned to #{variable_name}") + end end # Ensure correct object is reassigned to other accessors |