From 4f37b97033f596ec2c95eb53e9964e051c224981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 8 Sep 2009 10:10:14 -0500 Subject: Changed ActiveRecord to use new callbacks and speed up observers by only notifying events that are actually being consumed. Signed-off-by: Joshua Peek --- activerecord/test/models/topic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/test/models/topic.rb') diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index 9594dc300a..c16a6f2be9 100644 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -77,4 +77,4 @@ module Web class Topic < ActiveRecord::Base has_many :replies, :dependent => :destroy, :foreign_key => "parent_id", :class_name => 'Web::Reply' end -end \ No newline at end of file +end -- cgit v1.2.3 From 2ea1d684d93bd59887a9fd12e647941f0d1f4868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 8 Sep 2009 10:22:45 -0500 Subject: Refactor new callbacks and AR implementation. Signed-off-by: Joshua Peek --- activerecord/test/models/topic.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'activerecord/test/models/topic.rb') diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index c16a6f2be9..baca4972cb 100644 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -52,6 +52,15 @@ class Topic < ActiveRecord::Base id end + before_validation :before_validation_for_transaction + before_save :before_save_for_transaction + before_destroy :before_destroy_for_transaction + + after_save :after_save_for_transaction + after_create :after_create_for_transaction + + after_initialize :set_email_address + protected def approved=(val) @custom_approved = val @@ -66,11 +75,17 @@ class Topic < ActiveRecord::Base self.class.delete_all "parent_id = #{id}" end - def after_initialize + def set_email_address if self.new_record? self.author_email_address = 'test@test.com' end end + + def before_validation_for_transaction; end + def before_save_for_transaction; end + def before_destroy_for_transaction; end + def after_save_for_transaction; end + def after_create_for_transaction; end end module Web -- cgit v1.2.3