aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-01-31 18:32:28 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2010-02-01 02:02:42 -0800
commite5ab4b0d07ade8d89d633ca744c0eafbc53ee921 (patch)
treeaa2480b38f79e623b98da0274695f99db73bff20 /actionpack/lib/abstract_controller
parent8ae25a8e41168801590fdb95891cc5990b4db21c (diff)
downloadrails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.tar.gz
rails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.tar.bz2
rails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.zip
Convert to class_attribute
Diffstat (limited to 'actionpack/lib/abstract_controller')
-rw-r--r--actionpack/lib/abstract_controller/helpers.rb10
-rw-r--r--actionpack/lib/abstract_controller/layouts.rb8
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb18
3 files changed, 23 insertions, 13 deletions
diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb
index eb621c0865..578b884a4d 100644
--- a/actionpack/lib/abstract_controller/helpers.rb
+++ b/actionpack/lib/abstract_controller/helpers.rb
@@ -1,4 +1,6 @@
require 'active_support/dependencies'
+require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/delegation'
module AbstractController
module Helpers
@@ -12,10 +14,10 @@ module AbstractController
end
included do
- extlib_inheritable_accessor(:_helpers) { Module.new }
- extlib_inheritable_accessor(:_helper_serial) do
- AbstractController::Helpers.next_serial
- end
+ class_attribute :_helpers, :_helper_serial
+ delegate :_helpers, :to => :'self.class'
+ self._helpers = Module.new
+ self._helper_serial = ::AbstractController::Helpers.next_serial
end
module ClassMethods
diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb
index 56ddf9bf01..0d214396aa 100644
--- a/actionpack/lib/abstract_controller/layouts.rb
+++ b/actionpack/lib/abstract_controller/layouts.rb
@@ -1,3 +1,6 @@
+require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/delegation'
+
module AbstractController
# Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in
# repeated setups. The inclusion pattern has pages that look like this:
@@ -161,8 +164,9 @@ module AbstractController
include Rendering
included do
- extlib_inheritable_accessor(:_layout_conditions) { Hash.new }
- extlib_inheritable_accessor(:_action_has_layout) { Hash.new }
+ class_attribute :_layout_conditions
+ delegate :_layout_conditions, :to => :'self.class'
+ self._layout_conditions = {}
_write_layout_method
end
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index ac407bda5e..619a49571b 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -1,4 +1,7 @@
require "abstract_controller/base"
+require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/delegation'
+require 'active_support/core_ext/array/wrap'
module AbstractController
class DoubleRenderError < Error
@@ -13,8 +16,9 @@ module AbstractController
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor :_view_paths
- self._view_paths ||= ActionView::PathSet.new
+ class_attribute :_view_paths
+ delegate :_view_paths, :to => :'self.class'
+ self._view_paths = ActionView::PathSet.new
end
# An instance of a view class. The default view class is ActionView::Base
@@ -156,7 +160,6 @@ module AbstractController
elsif options.key?(:file)
options[:_template_name] = options[:file]
end
-
name = (options[:_template_name] || options[:action] || action_name).to_s
options[:_prefix] ||= _prefix if (options.keys & [:partial, :file, :template]).empty?
@@ -201,7 +204,7 @@ module AbstractController
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
def append_view_path(path)
- self.view_paths << path
+ self.view_paths = view_paths.dup + Array.wrap(path)
end
# Prepend a path to the list of view paths for this controller.
@@ -212,12 +215,12 @@ module AbstractController
# (see ActionView::ViewPathSet for more information)
def prepend_view_path(path)
clear_template_caches!
- self.view_paths.unshift(path)
+ self.view_paths = Array.wrap(path) + view_paths.dup
end
# A list of all of the default view paths for this controller.
def view_paths
- self._view_paths
+ _view_paths
end
# Set the view paths.
@@ -228,7 +231,8 @@ module AbstractController
def view_paths=(paths)
clear_template_caches!
self._view_paths = paths.is_a?(ActionView::PathSet) ? paths : ActionView::Base.process_view_paths(paths)
+ _view_paths.freeze
end
end
end
-end \ No newline at end of file
+end