aboutsummaryrefslogtreecommitdiffstats
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
parent8ae25a8e41168801590fdb95891cc5990b4db21c (diff)
downloadrails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.tar.gz
rails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.tar.bz2
rails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.zip
Convert to class_attribute
-rw-r--r--actionmailer/lib/action_mailer/base.rb10
-rw-r--r--actionmailer/lib/action_mailer/delivery_methods.rb14
-rw-r--r--actionmailer/lib/action_mailer/deprecated_api.rb2
-rw-r--r--actionmailer/test/base_test.rb24
-rw-r--r--actionmailer/test/delivery_methods_test.rb6
-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
-rw-r--r--actionpack/lib/action_controller/metal.rb9
-rw-r--r--actionpack/lib/action_controller/metal/helpers.rb4
-rw-r--r--actionpack/lib/action_controller/metal/hide_actions.rb9
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb21
-rw-r--r--actionpack/lib/action_controller/metal/renderers.rb10
-rw-r--r--actionpack/lib/action_controller/metal/request_forgery_protection.rb6
-rw-r--r--actionpack/lib/action_controller/metal/url_for.rb7
-rw-r--r--actionpack/lib/action_view/base.rb3
-rw-r--r--actionpack/lib/action_view/template/handler.rb4
-rw-r--r--actionpack/lib/action_view/template/resolver.rb3
-rw-r--r--actionpack/test/controller/view_paths_test.rb4
-rw-r--r--activerecord/lib/active_record/observer.rb9
-rw-r--r--activesupport/lib/active_support/rescuable.rb8
-rw-r--r--railties/lib/rails/generators/test_case.rb7
22 files changed, 113 insertions, 83 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index aa9822c6ab..ec85a20f70 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -268,13 +268,13 @@ module ActionMailer #:nodoc:
private_class_method :new #:nodoc:
- extlib_inheritable_accessor :default_params
+ class_attribute :default_params
self.default_params = {
:mime_version => "1.0",
:charset => "utf-8",
:content_type => "text/plain",
:parts_order => [ "text/plain", "text/enriched", "text/html" ]
- }
+ }.freeze
class << self
@@ -284,9 +284,9 @@ module ActionMailer #:nodoc:
attr_writer :mailer_name
alias :controller_path :mailer_name
- def default(value=nil)
- self.default_params.merge!(value) if value
- self.default_params
+ def default(value = nil)
+ self.default_params = default_params.merge(value).freeze if value
+ default_params
end
# Receives a raw email, parses it into an email object, decodes it,
diff --git a/actionmailer/lib/action_mailer/delivery_methods.rb b/actionmailer/lib/action_mailer/delivery_methods.rb
index 7e92aea8fd..043794bb12 100644
--- a/actionmailer/lib/action_mailer/delivery_methods.rb
+++ b/actionmailer/lib/action_mailer/delivery_methods.rb
@@ -7,8 +7,7 @@ module ActionMailer
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor :delivery_methods, :delivery_method,
- :instance_writer => false
+ class_attribute :delivery_methods, :delivery_method
# Do not make this inheritable, because we always want it to propagate
cattr_accessor :raise_delivery_errors
@@ -17,7 +16,7 @@ module ActionMailer
cattr_accessor :perform_deliveries
self.perform_deliveries = true
- self.delivery_methods = {}
+ self.delivery_methods = {}.freeze
self.delivery_method = :smtp
add_delivery_method :smtp, Mail::SMTP,
@@ -53,12 +52,9 @@ module ActionMailer
# :arguments => '-i -t'
#
def add_delivery_method(symbol, klass, default_options={})
- unless respond_to?(:"#{symbol}_settings")
- extlib_inheritable_accessor(:"#{symbol}_settings", :instance_writer => false)
- end
-
+ class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
send(:"#{symbol}_settings=", default_options)
- self.delivery_methods[symbol.to_sym] = klass
+ self.delivery_methods = delivery_methods.merge(symbol.to_sym => klass).freeze
end
def wrap_delivery_behavior(mail, method=nil) #:nodoc:
@@ -87,4 +83,4 @@ module ActionMailer
self.class.wrap_delivery_behavior(message, *args)
end
end
-end \ No newline at end of file
+end
diff --git a/actionmailer/lib/action_mailer/deprecated_api.rb b/actionmailer/lib/action_mailer/deprecated_api.rb
index 54ad18f796..c08ab4164e 100644
--- a/actionmailer/lib/action_mailer/deprecated_api.rb
+++ b/actionmailer/lib/action_mailer/deprecated_api.rb
@@ -47,7 +47,7 @@ module ActionMailer
end
def template_root=(root)
- ActiveSupport::Deprecation.warn "template_root= is deprecated, use view_paths.unshift instead", caller[0,2]
+ ActiveSupport::Deprecation.warn "template_root= is deprecated, use prepend_view_path instead", caller[0,2]
self.view_paths = ActionView::Base.process_view_paths(root)
end
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 57bfe2375e..20ecfdcbdb 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -254,7 +254,7 @@ class BaseTest < ActiveSupport::TestCase
end
test "subject gets default from I18n" do
- BaseMailer.default[:subject] = nil
+ BaseMailer.default :subject => nil
email = BaseMailer.welcome(:subject => nil)
assert_equal "Welcome", email.subject
@@ -331,22 +331,24 @@ class BaseTest < ActiveSupport::TestCase
end
test "implicit multipart with several view paths uses the first one with template" do
+ old = BaseMailer.view_paths
begin
- BaseMailer.view_paths.unshift(File.join(FIXTURE_LOAD_PATH, "another.path"))
+ BaseMailer.view_paths = [File.join(FIXTURE_LOAD_PATH, "another.path")] + old.dup
email = BaseMailer.welcome
assert_equal("Welcome from another path", email.body.encoded)
ensure
- BaseMailer.view_paths.shift
+ BaseMailer.view_paths = old
end
end
test "implicit multipart with inexistent templates uses the next view path" do
+ old = BaseMailer.view_paths
begin
- BaseMailer.view_paths.unshift(File.join(FIXTURE_LOAD_PATH, "unknown"))
+ BaseMailer.view_paths = [File.join(FIXTURE_LOAD_PATH, "unknown")] + old.dup
email = BaseMailer.welcome
assert_equal("Welcome", email.body.encoded)
ensure
- BaseMailer.view_paths.shift
+ BaseMailer.view_paths = old
end
end
@@ -503,16 +505,10 @@ class BaseTest < ActiveSupport::TestCase
end
def with_default(klass, new_values)
- hash = klass.default
- old_values = {}
- new_values.each do |key, value|
- old_values[key] = hash[key]
- hash[key] = value
- end
+ old = klass.default_params
+ klass.default(new_values)
yield
ensure
- old_values.each do |key, value|
- hash[key] = value
- end
+ klass.default_params = old
end
end
diff --git a/actionmailer/test/delivery_methods_test.rb b/actionmailer/test/delivery_methods_test.rb
index 4907ca0903..22a7d19bc2 100644
--- a/actionmailer/test/delivery_methods_test.rb
+++ b/actionmailer/test/delivery_methods_test.rb
@@ -45,7 +45,9 @@ class CustomDeliveryMethodsTest < ActiveSupport::TestCase
def teardown
ActionMailer::Base.delivery_method = @old_delivery_method
- ActionMailer::Base.delivery_methods.delete(:custom)
+ new = ActionMailer::Base.delivery_methods.dup
+ new.delete(:custom)
+ ActionMailer::Base.delivery_methods = new
end
test "allow to add custom delivery method" do
@@ -167,4 +169,4 @@ class MailDeliveryTest < ActiveSupport::TestCase
assert_equal(0, DeliveryMailer.deliveries.length)
end
-end \ No newline at end of file
+end
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
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index 57627a6f0b..2b35e111ec 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/class/inheritable_attributes'
+require 'active_support/core_ext/class/attribute'
module ActionController
# ActionController::Metal provides a way to get a valid Rack application from a controller.
@@ -90,7 +90,12 @@ module ActionController
end
end
- extlib_inheritable_accessor(:middleware_stack) { ActionDispatch::MiddlewareStack.new }
+ class_attribute :middleware_stack
+ self.middleware_stack = ActionDispatch::MiddlewareStack.new
+
+ def self.inherited(base)
+ self.middleware_stack = base.middleware_stack.dup
+ end
def self.use(*args)
middleware_stack.use(*args)
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb
index 05843a061b..1b5a4c3080 100644
--- a/actionpack/lib/action_controller/metal/helpers.rb
+++ b/actionpack/lib/action_controller/metal/helpers.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
# The Rails framework provides a large number of helpers for working with +assets+, +dates+, +forms+,
# +numbers+ and model objects, to name a few. These helpers are available to all templates
@@ -50,7 +52,7 @@ module ActionController
include AbstractController::Helpers
included do
- extlib_inheritable_accessor(:helpers_path)
+ class_attribute :helpers_path
self.helpers_path = []
end
diff --git a/actionpack/lib/action_controller/metal/hide_actions.rb b/actionpack/lib/action_controller/metal/hide_actions.rb
index cdacdc40a6..e893acffdf 100644
--- a/actionpack/lib/action_controller/metal/hide_actions.rb
+++ b/actionpack/lib/action_controller/metal/hide_actions.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
# ActionController::HideActions adds the ability to prevent public methods on a controller
# to be called as actions.
@@ -5,7 +7,8 @@ module ActionController
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor(:hidden_actions) { Set.new }
+ class_attribute :hidden_actions
+ self.hidden_actions = Set.new
end
private
@@ -14,7 +17,7 @@ module ActionController
# action name is in the list of hidden actions.
def action_method?(action_name)
self.class.visible_action?(action_name) do
- !hidden_actions.include?(action_name) && super
+ !self.class.hidden_actions.include?(action_name) && super
end
end
@@ -24,7 +27,7 @@ module ActionController
# ==== Parameters
# *args<#to_s>:: A list of actions
def hide_action(*args)
- hidden_actions.merge(args.map! {|a| a.to_s })
+ self.hidden_actions = hidden_actions.dup.merge(args.map(&:to_s))
end
def inherited(klass)
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index 08599d660e..e70a20b2be 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -1,11 +1,12 @@
require 'abstract_controller/collector'
+require 'active_support/core_ext/class/attribute'
module ActionController #:nodoc:
module MimeResponds #:nodoc:
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor :responder, :mimes_for_respond_to, :instance_writer => false
+ class_attribute :responder, :mimes_for_respond_to
self.responder = ActionController::Responder
clear_respond_to
end
@@ -38,18 +39,20 @@ module ActionController #:nodoc:
only_actions = Array(options.delete(:only))
except_actions = Array(options.delete(:except))
+ new = mimes_for_respond_to.dup
mimes.each do |mime|
mime = mime.to_sym
- mimes_for_respond_to[mime] = {}
- mimes_for_respond_to[mime][:only] = only_actions unless only_actions.empty?
- mimes_for_respond_to[mime][:except] = except_actions unless except_actions.empty?
+ new[mime] = {}
+ new[mime][:only] = only_actions unless only_actions.empty?
+ new[mime][:except] = except_actions unless except_actions.empty?
end
+ self.mimes_for_respond_to = new.freeze
end
# Clear all mimes in respond_to.
#
def clear_respond_to
- self.mimes_for_respond_to = ActiveSupport::OrderedHash.new
+ self.mimes_for_respond_to = ActiveSupport::OrderedHash.new.freeze
end
end
@@ -218,12 +221,12 @@ module ActionController #:nodoc:
#
def respond_with(*resources, &block)
raise "In order to use respond_with, first you need to declare the formats your " <<
- "controller responds to in the class level" if mimes_for_respond_to.empty?
+ "controller responds to in the class level" if self.class.mimes_for_respond_to.empty?
if response = retrieve_response_from_mimes(&block)
options = resources.extract_options!
options.merge!(:default_response => response)
- (options.delete(:responder) || responder).call(self, resources, options)
+ (options.delete(:responder) || self.class.responder).call(self, resources, options)
end
end
@@ -235,8 +238,8 @@ module ActionController #:nodoc:
def collect_mimes_from_class_level #:nodoc:
action = action_name.to_sym
- mimes_for_respond_to.keys.select do |mime|
- config = mimes_for_respond_to[mime]
+ self.class.mimes_for_respond_to.keys.select do |mime|
+ config = self.class.mimes_for_respond_to[mime]
if config[:except]
!config[:except].include?(action)
diff --git a/actionpack/lib/action_controller/metal/renderers.rb b/actionpack/lib/action_controller/metal/renderers.rb
index c1ba47927a..639b508746 100644
--- a/actionpack/lib/action_controller/metal/renderers.rb
+++ b/actionpack/lib/action_controller/metal/renderers.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
def self.add_renderer(key, &block)
Renderers.add(key, &block)
@@ -7,8 +9,8 @@ module ActionController
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor :_renderers
- self._renderers = {}
+ class_attribute :_renderers
+ self._renderers = {}.freeze
end
module ClassMethods
@@ -30,9 +32,11 @@ module ActionController
end
def use_renderers(*args)
+ new = _renderers.dup
args.each do |key|
- _renderers[key] = RENDERERS[key]
+ new[key] = RENDERERS[key]
end
+ self._renderers = new.freeze
_write_render_options
end
alias use_renderer use_renderers
diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
index f1fb4d7ce5..276c703307 100644
--- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb
+++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController #:nodoc:
class InvalidAuthenticityToken < ActionControllerError #:nodoc:
end
@@ -13,7 +15,7 @@ module ActionController #:nodoc:
cattr_accessor :request_forgery_protection_token
# Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode.
- extlib_inheritable_accessor :allow_forgery_protection
+ class_attribute :allow_forgery_protection
self.allow_forgery_protection = true
helper_method :form_authenticity_token
@@ -107,7 +109,7 @@ module ActionController #:nodoc:
end
def protect_against_forgery?
- allow_forgery_protection
+ self.class.allow_forgery_protection
end
end
end
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb
index 387e6a554b..51702368c1 100644
--- a/actionpack/lib/action_controller/metal/url_for.rb
+++ b/actionpack/lib/action_controller/metal/url_for.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
# In <b>routes.rb</b> one defines URL-to-controller mappings, but the reverse
# is also possible: an URL can be generated from one of your routing definitions.
@@ -85,9 +87,8 @@ module ActionController
included do
ActionController::Routing::Routes.install_helpers(self)
- extlib_inheritable_accessor :default_url_options,
- :instance_writer => false, :instance_reader => false
- self.default_url_options ||= {}
+ class_attribute :default_url_options
+ self.default_url_options = {}
end
# Overwrite to implement a number of default options that all url_for-based methods will use. The default options should come in
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 148d507f1c..4096c296c3 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -1,5 +1,6 @@
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'
+require 'active_support/core_ext/class/attribute'
module ActionView #:nodoc:
class ActionViewError < StandardError #:nodoc:
@@ -244,7 +245,7 @@ module ActionView #:nodoc:
ActionView::PathSet.new(Array(value))
end
- extlib_inheritable_accessor :helpers
+ class_attribute :helpers
attr_reader :helpers
def self.for_controller(controller)
diff --git a/actionpack/lib/action_view/template/handler.rb b/actionpack/lib/action_view/template/handler.rb
index 221d1bd5c5..8ecc911519 100644
--- a/actionpack/lib/action_view/template/handler.rb
+++ b/actionpack/lib/action_view/template/handler.rb
@@ -1,5 +1,5 @@
-require "active_support/core_ext/class/inheritable_attributes"
require "action_dispatch/http/mime_type"
+require 'active_support/core_ext/class/attribute'
# Legacy TemplateHandler stub
module ActionView
@@ -23,7 +23,7 @@ module ActionView
end
class Template::Handler
- extlib_inheritable_accessor :default_format
+ class_attribute :default_format
self.default_format = Mime::HTML
def self.call(template)
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index af5d6f6d18..6878067f7c 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -1,5 +1,6 @@
require "pathname"
require "active_support/core_ext/class"
+require "active_support/core_ext/array/wrap"
require "action_view/template"
module ActionView
@@ -11,7 +12,7 @@ module ActionView
def self.register_detail(name, options = {})
registered_details[name] = lambda do |val|
- val ||= yield
+ val = Array.wrap(val || yield)
val |= [nil] unless options[:allow_nil] == false
val
end
diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb
index 05d2c8407c..56821332c5 100644
--- a/actionpack/test/controller/view_paths_test.rb
+++ b/actionpack/test/controller/view_paths_test.rb
@@ -142,9 +142,9 @@ class ViewLoadPathsTest < ActionController::TestCase
assert_paths A, "a/path"
assert_paths A, *B.view_paths
assert_paths C, *original_load_paths
-
+
C.view_paths = []
- assert_nothing_raised { C.view_paths << 'c/path' }
+ assert_nothing_raised { C.append_view_path 'c/path' }
assert_paths C, "c/path"
end
end
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb
index 4e05b819b5..0fbb1f0261 100644
--- a/activerecord/lib/active_record/observer.rb
+++ b/activerecord/lib/active_record/observer.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActiveRecord
# Observer classes respond to lifecycle callbacks to implement trigger-like
# behavior outside the original class. This is a great way to reduce the
@@ -85,7 +87,8 @@ module ActiveRecord
# singletons and that call instantiates and registers them.
#
class Observer < ActiveModel::Observer
- extlib_inheritable_accessor(:observed_methods){ [] }
+ class_attribute :observed_methods
+ self.observed_methods = []
def initialize
super
@@ -93,7 +96,7 @@ module ActiveRecord
end
def self.method_added(method)
- observed_methods << method if ActiveRecord::Callbacks::CALLBACKS.include?(method.to_sym)
+ self.observed_methods += [method] if ActiveRecord::Callbacks::CALLBACKS.include?(method.to_sym)
end
protected
@@ -106,7 +109,7 @@ module ActiveRecord
# Check if a notifier callback was already added to the given class. If
# it was not, add it.
- self.observed_methods.each do |method|
+ self.class.observed_methods.each do |method|
callback = :"_notify_observers_for_#{method}"
if (klass.instance_methods & [callback, callback.to_s]).empty?
klass.class_eval "def #{callback}; notify_observers(:#{method}); end"
diff --git a/activesupport/lib/active_support/rescuable.rb b/activesupport/lib/active_support/rescuable.rb
index 6e660f8647..e4c1651acf 100644
--- a/activesupport/lib/active_support/rescuable.rb
+++ b/activesupport/lib/active_support/rescuable.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/class/inheritable_attributes'
+require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/proc'
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/array/extract_options'
@@ -9,7 +9,7 @@ module ActiveSupport
extend Concern
included do
- class_inheritable_accessor :rescue_handlers
+ class_attribute :rescue_handlers
self.rescue_handlers = []
end
@@ -67,7 +67,7 @@ module ActiveSupport
end
# put the new handler at the end because the list is read in reverse
- rescue_handlers << [key, options[:with]]
+ self.rescue_handlers += [[key, options[:with]]]
end
end
end
@@ -83,7 +83,7 @@ module ActiveSupport
def handler_for_rescue(exception)
# We go from right to left because pairs are pushed onto rescue_handlers
# as rescue_from declarations are found.
- _, rescuer = rescue_handlers.reverse.detect do |klass_name, handler|
+ _, rescuer = self.class.rescue_handlers.reverse.detect do |klass_name, handler|
# The purpose of allowing strings in rescue_from is to support the
# declaration of handler associations for exception classes whose
# definition is yet unknown.
diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb
index 38a3cbb035..6b97c69d8d 100644
--- a/railties/lib/rails/generators/test_case.rb
+++ b/railties/lib/rails/generators/test_case.rb
@@ -1,4 +1,5 @@
-require 'active_support/core_ext/class/inheritable_attributes'
+require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/hash/reverse_merge'
require 'rails/generators'
require 'fileutils'
@@ -28,8 +29,8 @@ module Rails
class TestCase < ActiveSupport::TestCase
include FileUtils
- extlib_inheritable_accessor :destination_root, :current_path, :generator_class,
- :default_arguments, :instance_writer => false
+ class_attribute :destination_root, :current_path, :generator_class, :default_arguments
+ delegate :destination_root, :current_path, :generator_class, :default_arguments, :to => :'self.class'
# Generators frequently change the current path using +FileUtils.cd+.
# So we need to store the path at file load and revert back to it after each test.