aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/callbacks.rb
diff options
context:
space:
mode:
authorozzyaaron <aaron@thefrontiergroup.com.au>2011-03-29 11:22:16 +0800
committerozzyaaron <aaron@thefrontiergroup.com.au>2011-03-29 11:22:16 +0800
commitd5dc02b5e88324bdbd274a5008a1d6b7a2f6f9d7 (patch)
tree4e91e467977678d7792867871cae69141b90c30d /activerecord/lib/active_record/callbacks.rb
parent62dd3458e326b1f2927d43401e7b10004410fdf0 (diff)
downloadrails-d5dc02b5e88324bdbd274a5008a1d6b7a2f6f9d7.tar.gz
rails-d5dc02b5e88324bdbd274a5008a1d6b7a2f6f9d7.tar.bz2
rails-d5dc02b5e88324bdbd274a5008a1d6b7a2f6f9d7.zip
Added back the Callback debugging section by interrogating the _*_callbacks method
Diffstat (limited to 'activerecord/lib/active_record/callbacks.rb')
-rw-r--r--activerecord/lib/active_record/callbacks.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 86d58df99b..a175bf003c 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -214,6 +214,24 @@ module ActiveRecord
# needs to be aware of it because an ordinary +save+ will raise such exception
# instead of quietly returning +false+.
#
+ # == Debugging callbacks
+ #
+ # The callback chain is accessible via the <tt>_*_callbacks</tt> method on an object. ActiveModel Callbacks support
+ # <tt>:before</tt>, <tt>:after</tt> and <tt>:around</tt> as values for the <tt>kind</tt> property. The <tt>kind</tt> property
+ # defines what part of the chain the callback runs in.
+ #
+ # To find all callbacks in the before_save callback chain:
+ #
+ # Topic._save_callbacks.select { |cb| cb.kind.eql?(:before) }
+ #
+ # Returns an array of callback objects that form the before_save chain.
+ #
+ # To further check if the before_save chain contains a proc defined as <tt>rest_when_dead</tt> use the <tt>filter</tt> property of the callback object:
+ #
+ # Topic._save_callbacks.select { |cb| cb.kind.eql?(:before) }.collect(&:filter).include?(:rest_when_dead)
+ #
+ # Returns true or false depending on whether the proc is contained in the before_save callback chain on a Topic model.
+ #
module Callbacks
extend ActiveSupport::Concern