aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--actionmailer/CHANGELOG2
-rw-r--r--actionmailer/lib/action_mailer/helpers.rb6
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/benchmarking.rb7
-rw-r--r--actionpack/lib/action_controller/components.rb11
-rw-r--r--actionpack/lib/action_controller/filters.rb11
-rw-r--r--actionpack/lib/action_controller/flash.rb7
-rw-r--r--actionpack/lib/action_controller/helpers.rb3
-rw-r--r--actionpack/lib/action_controller/integration.rb5
-rw-r--r--actionpack/lib/action_controller/layout.rb5
-rw-r--r--actionpack/lib/action_controller/rescue.rb3
-rw-r--r--actionpack/lib/action_controller/session_management.rb9
-rw-r--r--actionpack/lib/action_controller/test_process.rb3
-rw-r--r--actionwebservice/CHANGELOG2
-rw-r--r--actionwebservice/lib/action_web_service/container/action_controller_container.rb6
-rw-r--r--actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb3
-rw-r--r--actionwebservice/lib/action_web_service/invocation.rb3
-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
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb3
25 files changed, 52 insertions, 96 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG
index bf23f7b4dd..1a25b310b9 100644
--- a/actionmailer/CHANGELOG
+++ b/actionmailer/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.]
* Correct spurious documentation example code which results in a SyntaxError. [Marcel Molina Jr.]
diff --git a/actionmailer/lib/action_mailer/helpers.rb b/actionmailer/lib/action_mailer/helpers.rb
index ee7523a507..8176ba8a9a 100644
--- a/actionmailer/lib/action_mailer/helpers.rb
+++ b/actionmailer/lib/action_mailer/helpers.rb
@@ -11,14 +11,12 @@ module ActionMailer
base.class_eval do
# Wrap inherited to create a new master helper module for subclasses.
class << self
- alias_method :inherited_without_helper, :inherited
- alias_method :inherited, :inherited_with_helper
+ alias_method_chain :inherited, :helper
end
# Wrap initialize_template_class to extend new template class
# instances with the master helper module.
- alias_method :initialize_template_class_without_helper, :initialize_template_class
- alias_method :initialize_template_class, :initialize_template_class_with_helper
+ alias_method_chain :initialize_template_class, :helper
end
end
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 865aec8672..1d28af1c3d 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/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.]
* Use #flush between switching from #write to #syswrite. Closes #4907. [Blair Zajac <blair@orcaware.com>]
diff --git a/actionpack/lib/action_controller/benchmarking.rb b/actionpack/lib/action_controller/benchmarking.rb
index a30212c8bd..8b548f9d25 100644
--- a/actionpack/lib/action_controller/benchmarking.rb
+++ b/actionpack/lib/action_controller/benchmarking.rb
@@ -8,11 +8,8 @@ module ActionController #:nodoc:
base.extend(ClassMethods)
base.class_eval do
- alias_method :perform_action_without_benchmark, :perform_action
- alias_method :perform_action, :perform_action_with_benchmark
-
- alias_method :render_without_benchmark, :render
- alias_method :render, :render_with_benchmark
+ alias_method_chain :perform_action, :benchmark
+ alias_method_chain :render, :benchmark
end
end
diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb
index 75005daaec..c746928697 100644
--- a/actionpack/lib/action_controller/components.rb
+++ b/actionpack/lib/action_controller/components.rb
@@ -50,14 +50,9 @@ module ActionController #:nodoc:
base.send :attr_accessor, :parent_controller
base.class_eval do
- alias_method :process_cleanup_without_components, :process_cleanup
- alias_method :process_cleanup, :process_cleanup_with_components
-
- alias_method :set_session_options_without_components, :set_session_options
- alias_method :set_session_options, :set_session_options_with_components
-
- alias_method :flash_without_components, :flash
- alias_method :flash, :flash_with_components
+ alias_method_chain :process_cleanup, :components
+ alias_method_chain :set_session_options, :components
+ alias_method_chain :flash, :components
alias_method :component_request?, :parent_controller
end
diff --git a/actionpack/lib/action_controller/filters.rb b/actionpack/lib/action_controller/filters.rb
index 01a4b9fba1..624124ac01 100644
--- a/actionpack/lib/action_controller/filters.rb
+++ b/actionpack/lib/action_controller/filters.rb
@@ -350,14 +350,9 @@ module ActionController #:nodoc:
module InstanceMethods # :nodoc:
def self.included(base)
base.class_eval do
- alias_method :perform_action_without_filters, :perform_action
- alias_method :perform_action, :perform_action_with_filters
-
- alias_method :process_without_filters, :process
- alias_method :process, :process_with_filters
-
- alias_method :process_cleanup_without_filters, :process_cleanup
- alias_method :process_cleanup, :process_cleanup_with_filters
+ alias_method_chain :perform_action, :filters
+ alias_method_chain :process, :filters
+ alias_method_chain :process_cleanup, :filters
end
end
diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb
index 8877c33741..61ac33f399 100644
--- a/actionpack/lib/action_controller/flash.rb
+++ b/actionpack/lib/action_controller/flash.rb
@@ -28,11 +28,8 @@ module ActionController #:nodoc:
base.send :include, InstanceMethods
base.class_eval do
- alias_method :assign_shortcuts_without_flash, :assign_shortcuts
- alias_method :assign_shortcuts, :assign_shortcuts_with_flash
-
- alias_method :process_cleanup_without_flash, :process_cleanup
- alias_method :process_cleanup, :process_cleanup_with_flash
+ alias_method_chain :assign_shortcuts, :flash
+ alias_method_chain :process_cleanup, :flash
end
end
diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb
index cdfcfd7e91..8aeef52868 100644
--- a/actionpack/lib/action_controller/helpers.rb
+++ b/actionpack/lib/action_controller/helpers.rb
@@ -12,8 +12,7 @@ module ActionController #:nodoc:
base.class_eval do
# Wrap inherited to create a new master helper module for subclasses.
class << self
- alias_method :inherited_without_helper, :inherited
- alias_method :inherited, :inherited_with_helper
+ alias_method_chain :inherited, :helper
end
end
end
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb
index 74817c4b4c..56ac4b74fe 100644
--- a/actionpack/lib/action_controller/integration.rb
+++ b/actionpack/lib/action_controller/integration.rb
@@ -317,9 +317,8 @@ module ActionController
def self.included(base)
base.extend(ClassMethods)
base.class_eval do
- class <<self
- alias_method :new_without_capture, :new
- alias_method :new, :new_with_capture
+ class << self
+ alias_method_chain :new, :capture
end
end
end
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index 4e9e42d468..f27e42ea17 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -3,12 +3,13 @@ module ActionController #:nodoc:
def self.included(base)
base.extend(ClassMethods)
base.class_eval do
+ # NOTE: Can't use alias_method_chain here because +render_without_layout+ is already
+ # defined as a publicly exposed method
alias_method :render_with_no_layout, :render
alias_method :render, :render_with_a_layout
class << self
- alias_method :inherited_without_layout, :inherited
- alias_method :inherited, :inherited_with_layout
+ alias_method_chain :inherited, :layout
end
end
end
diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb
index 9f0cd47092..9b57d35587 100644
--- a/actionpack/lib/action_controller/rescue.rb
+++ b/actionpack/lib/action_controller/rescue.rb
@@ -9,8 +9,7 @@ module ActionController #:nodoc:
def self.included(base) #:nodoc:
base.extend(ClassMethods)
base.class_eval do
- alias_method :perform_action_without_rescue, :perform_action
- alias_method :perform_action, :perform_action_with_rescue
+ alias_method_chain :perform_action, :rescue
end
end
diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb
index 408ef2790e..d953b5b766 100644
--- a/actionpack/lib/action_controller/session_management.rb
+++ b/actionpack/lib/action_controller/session_management.rb
@@ -8,12 +8,9 @@ module ActionController #:nodoc:
module SessionManagement #:nodoc:
def self.included(base)
base.extend(ClassMethods)
-
- base.send :alias_method, :process_without_session_management_support, :process
- base.send :alias_method, :process, :process_with_session_management_support
-
- base.send :alias_method, :process_cleanup_without_session_management_support, :process_cleanup
- base.send :alias_method, :process_cleanup, :process_cleanup_with_session_management_support
+
+ base.send :alias_method_chain, :process, :session_management_support
+ base.send :alias_method_chain, :process_cleanup, :session_management_support
end
module ClassMethods
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 096ccf76d2..b35439249d 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -18,8 +18,7 @@ module ActionController #:nodoc:
end
end
- alias_method :process_without_test, :process
- alias_method :process, :process_with_test
+ alias_method_chain :process, :test
end
class TestRequest < AbstractRequest #:nodoc:
diff --git a/actionwebservice/CHANGELOG b/actionwebservice/CHANGELOG
index c84787ef75..22bdd328aa 100644
--- a/actionwebservice/CHANGELOG
+++ b/actionwebservice/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.]
* Fix test database name typo. [Marcel Molina Jr.]
diff --git a/actionwebservice/lib/action_web_service/container/action_controller_container.rb b/actionwebservice/lib/action_web_service/container/action_controller_container.rb
index e96ee0692d..bbc28083c3 100644
--- a/actionwebservice/lib/action_web_service/container/action_controller_container.rb
+++ b/actionwebservice/lib/action_web_service/container/action_controller_container.rb
@@ -4,10 +4,8 @@ module ActionWebService # :nodoc:
def self.included(base) # :nodoc:
class << base
include ClassMethods
- alias_method :inherited_without_api, :inherited
- alias_method :inherited, :inherited_with_api
- alias_method :web_service_api_without_require, :web_service_api
- alias_method :web_service_api, :web_service_api_with_require
+ alias_method_chain :inherited, :api
+ alias_method_chain :web_service_api, :require
end
end
diff --git a/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb b/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
index f1fd6137f5..a338aedbc1 100644
--- a/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
+++ b/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
@@ -7,8 +7,7 @@ module ActionWebService # :nodoc:
def self.included(base) # :nodoc:
class << base
include ClassMethods
- alias_method :inherited_without_action_controller, :inherited
- alias_method :inherited, :inherited_with_action_controller
+ alias_method_chain :inherited, :action_controller
end
base.class_eval do
alias_method :web_service_direct_invoke_without_controller, :web_service_direct_invoke
diff --git a/actionwebservice/lib/action_web_service/invocation.rb b/actionwebservice/lib/action_web_service/invocation.rb
index c37e923fc7..2a9121ee26 100644
--- a/actionwebservice/lib/action_web_service/invocation.rb
+++ b/actionwebservice/lib/action_web_service/invocation.rb
@@ -126,8 +126,7 @@ module ActionWebService # :nodoc:
module InstanceMethods # :nodoc:
def self.included(base)
base.class_eval do
- alias_method :perform_invocation_without_interception, :perform_invocation
- alias_method :perform_invocation, :perform_invocation_with_interception
+ alias_method_chain :perform_invocation, :interception
end
end
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
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 7d20611df2..16052680da 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
+
* Strip out punctuation on predicates or bang methods being aliased with alias_method_chain since target?_without_feature is not a valid method name. Add tests for Module#alias_method_chain. [Marcel Molina Jr.]
* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 7c60d5bed5..8511a74d5c 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -3,8 +3,7 @@ module ActiveSupport #:nodoc:
module Time #:nodoc:
# Enables the use of time calculations within Time itself
module Calculations
- def self.append_features(base) #:nodoc:
- super
+ def self.included(base) #:nodoc:
base.extend(ClassMethods)
end