diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-07-03 08:27:18 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-07-03 08:27:18 +0000 |
commit | 9ebe33f14b10fc00b227a408b846b6d2329746b8 (patch) | |
tree | 14e1dc7c1fa0eab35f7678bc4af6b9529ba4d83d /activerecord/lib | |
parent | d9d22c7596118051ba8908c163c797b90cca7aa3 (diff) | |
download | rails-9ebe33f14b10fc00b227a408b846b6d2329746b8.tar.gz rails-9ebe33f14b10fc00b227a408b846b6d2329746b8.tar.bz2 rails-9ebe33f14b10fc00b227a408b846b6d2329746b8.zip |
r1601@asus: jeremy | 2005-07-02 14:33:08 -0700
Only notify observers of after_find and after_initialize if these methods are defined on the model.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1620 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/callbacks.rb | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index 8e95502e56..629272b639 100755 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -213,32 +213,29 @@ module ActiveRecord module ClassMethods #:nodoc: def instantiate_with_callbacks(record) object = instantiate_without_callbacks(record) - - if object.send(:respond_to_without_attributes?, :after_find) + + if object.respond_to_without_attributes?(:after_find) object.send(:callback, :after_find) - else - object.send(:invoke_and_notify, :after_find) end - if object.send(:respond_to_without_attributes?, :after_initialize) + if object.respond_to_without_attributes?(:after_initialize) object.send(:callback, :after_initialize) - else - object.send(:invoke_and_notify, :after_initialize) end - + object end end # Is called when the object was instantiated by one of the finders, like Base.find. - # def after_find() end + #def after_find() end # Is called after the object has been instantiated by a call to Base.new. - # def after_initialize() end + #def after_initialize() end + def initialize_with_callbacks(attributes = nil) #:nodoc: initialize_without_callbacks(attributes) result = yield self if block_given? - respond_to_without_attributes?(:after_initialize) ? callback(:after_initialize) : invoke_and_notify(:after_initialize) + callback(:after_initialize) if respond_to_without_attributes?(:after_initialize) result end |