From b67ec8ba20099c8b39bf344f385bbbd2b9c8f47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 10 Jun 2010 19:39:09 +0200 Subject: 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. --- actionpack/lib/action_view/base.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'actionpack/lib/action_view/base.rb') 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| "
#{html_tag}
".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 -- cgit v1.2.3