diff options
author | José Valim <jose.valim@gmail.com> | 2010-06-10 19:39:09 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-10 19:39:09 +0200 |
commit | b67ec8ba20099c8b39bf344f385bbbd2b9c8f47d (patch) | |
tree | 008a576bb72baffd49b2483b3b08e181933e29c1 /actionpack/lib/action_view | |
parent | c4d6245e875bbb276c122a5a401422d341dac4df (diff) | |
download | rails-b67ec8ba20099c8b39bf344f385bbbd2b9c8f47d.tar.gz rails-b67ec8ba20099c8b39bf344f385bbbd2b9c8f47d.tar.bz2 rails-b67ec8ba20099c8b39bf344f385bbbd2b9c8f47d.zip |
class_attribute is not a direct replacement of class_inheritable_*.
If you are setting a hash or an array in class_attribute or you need
to freeze it, to ensure people won't modify it in place or you need
to dup it on inheritance.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 7dd9dea358..2efc575081 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -158,7 +158,6 @@ module ActionView #:nodoc: end include Helpers, Rendering, Partials, Layouts, ::ERB::Util, Context - extend ActiveSupport::Memoizable # Specify whether RJS responses should be wrapped in a try/catch block # that alert()s the caught exception (and then re-raises it). @@ -170,9 +169,6 @@ module ActionView #:nodoc: @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe } class_attribute :helpers - remove_method :helpers - attr_reader :helpers - class_attribute :_router class << self @@ -201,20 +197,21 @@ module ActionView #:nodoc: end def self.process_view_paths(value) - return value.dup if value.is_a?(PathSet) - ActionView::PathSet.new(Array.wrap(value)) + value.is_a?(PathSet) ? + value.dup : ActionView::PathSet.new(Array.wrap(value)) end def initialize(lookup_context = nil, assigns_for_first_render = {}, controller = nil, formats = nil) #:nodoc: - @config = nil - @assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) } - @helpers = self.class.helpers || Module.new + self.assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) } + self.helpers = self.class.helpers || Module.new if @_controller = controller @_request = controller.request if controller.respond_to?(:request) end - @_config = ActiveSupport::InheritableOptions.new(controller.config) if controller && controller.respond_to?(:config) + config = controller && controller.respond_to?(:config) ? controller.config : {} + @_config = ActiveSupport::InheritableOptions.new(config) + @_content_for = Hash.new { |h,k| h[k] = ActiveSupport::SafeBuffer.new } @_virtual_path = nil @output_buffer = nil |