aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2011-01-09 10:15:05 -0800
committerSantiago Pastorino <santiago@wyeworks.com>2011-01-31 19:45:53 -0200
commit57bc25c5f8129f57b08a2dc7c319b86778dd8a40 (patch)
tree4e21728c5dd1866f654ed88d169552a77fa6483b
parent9666b6a625c9fef555c2a18df6721fed2000f131 (diff)
downloadrails-57bc25c5f8129f57b08a2dc7c319b86778dd8a40.tar.gz
rails-57bc25c5f8129f57b08a2dc7c319b86778dd8a40.tar.bz2
rails-57bc25c5f8129f57b08a2dc7c319b86778dd8a40.zip
Use run_callbacks; the generated _run_<name>_callbacks method is not a public interface.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
-rw-r--r--actionpack/lib/action_dispatch/middleware/callbacks.rb2
-rw-r--r--actionpack/lib/action_dispatch/middleware/reloader.rb8
-rw-r--r--activemodel/README.rdoc2
-rw-r--r--activemodel/lib/active_model/callbacks.rb5
-rw-r--r--activemodel/lib/active_model/validations.rb2
-rw-r--r--activemodel/lib/active_model/validations/callbacks.rb2
-rw-r--r--activemodel/test/cases/callbacks_test.rb4
-rw-r--r--activerecord/lib/active_record/base.rb6
-rw-r--r--activerecord/lib/active_record/callbacks.rb10
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb2
-rw-r--r--activerecord/lib/active_record/transactions.rb4
-rw-r--r--activesupport/lib/active_support/testing/setup_and_teardown.rb8
-rw-r--r--activesupport/test/callback_inheritance_test.rb2
-rw-r--r--activesupport/test/callbacks_test.rb2
14 files changed, 28 insertions, 31 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/callbacks.rb b/actionpack/lib/action_dispatch/middleware/callbacks.rb
index 4d038c29f2..1bb2ad7f67 100644
--- a/actionpack/lib/action_dispatch/middleware/callbacks.rb
+++ b/actionpack/lib/action_dispatch/middleware/callbacks.rb
@@ -25,7 +25,7 @@ module ActionDispatch
end
def call(env)
- _run_call_callbacks do
+ run_callbacks :call do
@app.call(env)
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/reloader.rb b/actionpack/lib/action_dispatch/middleware/reloader.rb
index f6ab368ad8..29289a76b4 100644
--- a/actionpack/lib/action_dispatch/middleware/reloader.rb
+++ b/actionpack/lib/action_dispatch/middleware/reloader.rb
@@ -43,12 +43,12 @@ module ActionDispatch
# Execute all prepare callbacks.
def self.prepare!
- new(nil).send(:_run_prepare_callbacks)
+ new(nil).run_callbacks :prepare
end
# Execute all cleanup callbacks.
def self.cleanup!
- new(nil).send(:_run_cleanup_callbacks)
+ new(nil).run_callbacks :cleanup
end
def initialize(app)
@@ -64,12 +64,12 @@ module ActionDispatch
end
def call(env)
- _run_prepare_callbacks
+ run_callbacks :prepare
response = @app.call(env)
response[2].extend(CleanupOnClose)
response
rescue Exception
- _run_cleanup_callbacks
+ run_callbacks :cleanup
raise
end
end
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index f3d4bf8fe3..d9a9bdae3e 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -41,7 +41,7 @@ modules:
define_model_callbacks :create
def create
- _run_create_callbacks do
+ run_callbacks :create do
# Your create action methods here
end
end
diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb
index 7302a869c8..2a1f51a9a7 100644
--- a/activemodel/lib/active_model/callbacks.rb
+++ b/activemodel/lib/active_model/callbacks.rb
@@ -24,14 +24,11 @@ module ActiveModel
# you want callbacks on in a block so that the callbacks get a chance to fire:
#
# def create
- # _run_create_callbacks do
+ # run_callbacks :create do
# # Your create action methods here
# end
# end
#
- # The _run_<method_name>_callbacks methods are dynamically created when you extend
- # the <tt>ActiveModel::Callbacks</tt> module.
- #
# Then in your class, you can use the +before_create+, +after_create+ and +around_create+
# methods, just as you would in an Active Record module.
#
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 6cb015a144..cdf23c7b1b 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -207,7 +207,7 @@ module ActiveModel
protected
def run_validations!
- _run_validate_callbacks
+ run_callbacks :validate
errors.empty?
end
end
diff --git a/activemodel/lib/active_model/validations/callbacks.rb b/activemodel/lib/active_model/validations/callbacks.rb
index 621518de5b..adc2867ad0 100644
--- a/activemodel/lib/active_model/validations/callbacks.rb
+++ b/activemodel/lib/active_model/validations/callbacks.rb
@@ -50,7 +50,7 @@ module ActiveModel
# Overwrite run validations to include callbacks.
def run_validations!
- _run_validation_callbacks { super }
+ run_callbacks(:validation) { super }
end
end
end
diff --git a/activemodel/test/cases/callbacks_test.rb b/activemodel/test/cases/callbacks_test.rb
index 069d907fb2..086e7266ff 100644
--- a/activemodel/test/cases/callbacks_test.rb
+++ b/activemodel/test/cases/callbacks_test.rb
@@ -37,7 +37,7 @@ class CallbacksTest < ActiveModel::TestCase
end
def create
- _run_create_callbacks do
+ run_callbacks :create do
@callbacks << :create
@valid
end
@@ -92,7 +92,7 @@ class CallbacksTest < ActiveModel::TestCase
def callback1; self.history << 'callback1'; end
def callback2; self.history << 'callback2'; end
def create
- _run_create_callbacks {}
+ run_callbacks(:create) {}
self
end
end
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 00324b14f2..220d861a27 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1400,7 +1400,7 @@ MSG
self.attributes = attributes unless attributes.nil?
result = yield self if block_given?
- _run_initialize_callbacks
+ run_callbacks :initialize
result
end
@@ -1437,8 +1437,8 @@ MSG
@aggregation_cache = {}
@readonly = @destroyed = @marked_for_destruction = false
@new_record = false
- _run_find_callbacks
- _run_initialize_callbacks
+ run_callbacks :find
+ run_callbacks :initialize
end
# Specifies how the record is dumped by +Marshal+.
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 47428cfd0f..8f137e3b21 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -237,25 +237,25 @@ module ActiveRecord
end
def destroy #:nodoc:
- _run_destroy_callbacks { super }
+ run_callbacks(:destroy) { super }
end
def touch(*) #:nodoc:
- _run_touch_callbacks { super }
+ run_callbacks(:touch) { super }
end
private
def create_or_update #:nodoc:
- _run_save_callbacks { super }
+ run_callbacks(:save) { super }
end
def create #:nodoc:
- _run_create_callbacks { super }
+ run_callbacks(:create) { super }
end
def update(*) #:nodoc:
- _run_update_callbacks { super }
+ run_callbacks(:update) { super }
end
end
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index cffa2387de..54f70c59f8 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -212,7 +212,7 @@ module ActiveRecord
# calling +checkout+ on this pool.
def checkin(conn)
@connection_mutex.synchronize do
- conn.send(:_run_checkin_callbacks) do
+ conn.run_callbacks :checkin do
@checked_out.delete conn
@queue.signal
end
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index 48d2f7c9a9..45a4425944 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -259,7 +259,7 @@ module ActiveRecord
# Call the after_commit callbacks
def committed! #:nodoc:
- _run_commit_callbacks
+ run_callbacks :commit
ensure
clear_transaction_record_state
end
@@ -267,7 +267,7 @@ module ActiveRecord
# Call the after rollback callbacks. The restore_state argument indicates if the record
# state should be rolled back to the beginning or just to the last savepoint.
def rolledback!(force_restore_state = false) #:nodoc:
- _run_rollback_callbacks
+ run_callbacks :rollback
ensure
restore_transaction_record_state(force_restore_state)
end
diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb
index b2d9ddfeb7..22e41fa905 100644
--- a/activesupport/lib/active_support/testing/setup_and_teardown.rb
+++ b/activesupport/lib/active_support/testing/setup_and_teardown.rb
@@ -31,14 +31,14 @@ module ActiveSupport
def run(runner)
result = '.'
begin
- _run_setup_callbacks do
+ run_callbacks :setup do
result = super
end
rescue Exception => e
result = runner.puke(self.class, method_name, e)
ensure
begin
- _run_teardown_callbacks
+ run_callbacks :teardown
rescue Exception => e
result = runner.puke(self.class, method_name, e)
end
@@ -62,7 +62,7 @@ module ActiveSupport
begin
begin
- _run_setup_callbacks do
+ run_callbacks :setup do
setup
__send__(@method_name)
mocha_verify(mocha_counter) if mocha_counter
@@ -77,7 +77,7 @@ module ActiveSupport
ensure
begin
teardown
- _run_teardown_callbacks
+ run_callbacks :teardown
rescue Test::Unit::AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Exception => e
diff --git a/activesupport/test/callback_inheritance_test.rb b/activesupport/test/callback_inheritance_test.rb
index 8caf000c5d..71249050fc 100644
--- a/activesupport/test/callback_inheritance_test.rb
+++ b/activesupport/test/callback_inheritance_test.rb
@@ -70,7 +70,7 @@ class EmptyParent
end
def dispatch
- _run_dispatch_callbacks
+ run_callbacks :dispatch
self
end
end
diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb
index c89b03e243..cff914f4ae 100644
--- a/activesupport/test/callbacks_test.rb
+++ b/activesupport/test/callbacks_test.rb
@@ -14,7 +14,7 @@ module CallbacksTest
def after_save1; self.history << :after; end
def save
- self.send(:_run_save_callbacks) do
+ run_callbacks :save do
raise 'boom'
end
end