aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG4
-rwxr-xr-xactiverecord/lib/active_record/callbacks.rb19
2 files changed, 12 insertions, 11 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index ebf3d3b244..25addad806 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,9 @@
*SVN*
+* Speed up ActiveRecord#method_missing for the common case (read_attribute).
+
+* Only notify observers on after_find and after_initialize if these methods are defined on the model. [skaes@web.de]
+
* Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath]
* Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at]
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