aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJosh Peek <josh@joshpeek.com>2008-04-04 20:26:42 +0000
committerJosh Peek <josh@joshpeek.com>2008-04-04 20:26:42 +0000
commit08318b8bcd32bae741e672899a33c6a7d52664c8 (patch)
tree5f7b491567621560d1c618e93fb8ab15155a3dbf /activerecord
parent36b8073ff553e8939d78ca2371ffdec7eb8f8071 (diff)
downloadrails-08318b8bcd32bae741e672899a33c6a7d52664c8.tar.gz
rails-08318b8bcd32bae741e672899a33c6a7d52664c8.tar.bz2
rails-08318b8bcd32bae741e672899a33c6a7d52664c8.zip
Replaced callback method evaluation in AssociationCollection class to use ActiveSupport::Callbacks. Modified ActiveSupport::Callbacks::Callback#call to accept multiple arguments.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9225 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb15
1 files changed, 2 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 3b8954e435..141fdcab3d 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -240,21 +240,10 @@ module ActiveRecord
def callback(method, record)
callbacks_for(method).each do |callback|
- case callback
- when Symbol
- @owner.send(callback, record)
- when Proc, Method
- callback.call(@owner, record)
- else
- if callback.respond_to?(method)
- callback.send(method, @owner, record)
- else
- raise ActiveRecordError, "Callbacks must be a symbol denoting the method to call, a string to be evaluated, a block to be invoked, or an object responding to the callback method."
- end
- end
+ ActiveSupport::Callbacks::Callback.new(method, callback, record).call(@owner, record)
end
end
-
+
def callbacks_for(callback_name)
full_callback_name = "#{callback_name}_for_#{@reflection.name}"
@owner.class.read_inheritable_attribute(full_callback_name.to_sym) || []