aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2006-04-29 20:20:22 +0000
committerMarcel Molina <marcel@vernix.org>2006-04-29 20:20:22 +0000
commit9f92dd39849c353b8a69401a93ba7b13f93d669f (patch)
tree115190ab4023a28f8dff3e54b42fa1c981bc7d14 /activerecord
parent995167ec2eced73f44d4f961349dbbee6b297210 (diff)
downloadrails-9f92dd39849c353b8a69401a93ba7b13f93d669f.tar.gz
rails-9f92dd39849c353b8a69401a93ba7b13f93d669f.tar.bz2
rails-9f92dd39849c353b8a69401a93ba7b13f93d669f.zip
Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4312 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/callbacks.rb23
-rw-r--r--activerecord/lib/active_record/locking.rb3
-rw-r--r--activerecord/lib/active_record/timestamp.rb8
-rw-r--r--activerecord/lib/active_record/transactions.rb8
-rwxr-xr-xactiverecord/lib/active_record/validations.rb11
6 files changed, 16 insertions, 39 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 906f0a39db..79fdae8b20 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
+
* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
* Remove duplicate fixture entry in comments.yml. Closes #4923. [Blair Zajac <blair@orcaware.com>]
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 26d8bfa7b6..d219efe727 100755
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -175,27 +175,12 @@ module ActiveRecord
base.class_eval do
class << self
include Observable
- alias_method :instantiate_without_callbacks, :instantiate
- alias_method :instantiate, :instantiate_with_callbacks
+ alias_method_chain :instantiate, :callbacks
end
- alias_method :initialize_without_callbacks, :initialize
- alias_method :initialize, :initialize_with_callbacks
-
- alias_method :create_or_update_without_callbacks, :create_or_update
- alias_method :create_or_update, :create_or_update_with_callbacks
-
- alias_method :valid_without_callbacks, :valid?
- alias_method :valid?, :valid_with_callbacks
-
- alias_method :create_without_callbacks, :create
- alias_method :create, :create_with_callbacks
-
- alias_method :update_without_callbacks, :update
- alias_method :update, :update_with_callbacks
-
- alias_method :destroy_without_callbacks, :destroy
- alias_method :destroy, :destroy_with_callbacks
+ [:initialize, :create_or_update, :valid?, :create, :update, :destroy].each do |method|
+ alias_method_chain method, :callbacks
+ end
end
CALLBACKS.each do |method|
diff --git a/activerecord/lib/active_record/locking.rb b/activerecord/lib/active_record/locking.rb
index 3e0c47e706..ee4224c004 100644
--- a/activerecord/lib/active_record/locking.rb
+++ b/activerecord/lib/active_record/locking.rb
@@ -23,8 +23,7 @@ module ActiveRecord
module Locking
def self.included(base) #:nodoc:
base.class_eval do
- alias_method :update_without_lock, :update
- alias_method :update, :update_with_lock
+ alias_method_chain :update, :lock
end
end
diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb
index 44936a1432..26fb0c17ac 100644
--- a/activerecord/lib/active_record/timestamp.rb
+++ b/activerecord/lib/active_record/timestamp.rb
@@ -8,11 +8,9 @@ module ActiveRecord
module Timestamp
def self.included(base) # :nodoc:
base.class_eval do
- alias_method :create_without_timestamps, :create
- alias_method :create, :create_with_timestamps
-
- alias_method :update_without_timestamps, :update
- alias_method :update, :update_with_timestamps
+ [:create, :update].each do |method|
+ alias_method_chain method, :timestamps
+ end
end
end
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index 01bbdf4c8a..c222e18097 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -13,11 +13,9 @@ module ActiveRecord
base.extend(ClassMethods)
base.class_eval do
- alias_method :destroy_without_transactions, :destroy
- alias_method :destroy, :destroy_with_transactions
-
- alias_method :save_without_transactions, :save
- alias_method :save, :save_with_transactions
+ [:destroy, :save].each do |method|
+ alias_method_chain method, :transactions
+ end
end
end
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index d66c5934fb..4194e68b2f 100755
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -217,14 +217,9 @@ module ActiveRecord
def self.included(base) # :nodoc:
base.extend ClassMethods
base.class_eval do
- alias_method :save_without_validation, :save
- alias_method :save, :save_with_validation
-
- alias_method :save_without_validation!, :save!
- alias_method :save!, :save_with_validation!
-
- alias_method :update_attribute_without_validation_skipping, :update_attribute
- alias_method :update_attribute, :update_attribute_with_validation_skipping
+ alias_method_chain :save, :validation
+ alias_method_chain :save!, :validation!
+ alias_method_chain :update_attribute, :validation_skipping
end
end