Skip to content

Commit

Permalink
Merge pull request #49342 from skipkayhil/hm-doc-callbacks
Browse files Browse the repository at this point in the history
Add links to Callbacks, note example definition [ci skip]
  • Loading branch information
skipkayhil committed Sep 21, 2023
2 parents 585e0ca + b5dbcb1 commit 23f130c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions activesupport/lib/active_support/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ def __update_callbacks(name) # :nodoc:
#
# The callback can be specified as a symbol naming an instance method; as a
# proc, lambda, or block; or as an object that responds to a certain method
# determined by the <tt>:scope</tt> argument to +define_callbacks+.
# determined by the <tt>:scope</tt> argument to #define_callbacks.
#
# If a proc, lambda, or block is given, its body is evaluated in the context
# of the current object. It can also optionally accept the current object as
Expand Down Expand Up @@ -787,10 +787,13 @@ def set_callback(name, *filter_list, &block)
end
end

# Skip a previously set callback. Like +set_callback+, <tt>:if</tt> or
# Skip a previously set callback. Like #set_callback, <tt>:if</tt> or
# <tt>:unless</tt> options may be passed in order to control when the
# callback is skipped.
#
# Note: this example uses +PersonRecord+ and +#saving_message+, which you
# can see defined here[rdoc-ref:ActiveSupport::Callbacks]
#
# class Writer < PersonRecord
# attr_accessor :age
# skip_callback :save, :before, :saving_message, if: -> { age > 18 }
Expand Down Expand Up @@ -933,7 +936,7 @@ def reset_callbacks(name)
# <tt>!</tt>, <tt>?</tt> or <tt>=</tt>.
#
# Calling +define_callbacks+ multiple times with the same +names+ will
# overwrite previous callbacks registered with +set_callback+.
# overwrite previous callbacks registered with #set_callback.
def define_callbacks(*names)
options = names.extract_options!

Expand Down

0 comments on commit 23f130c

Please sign in to comment.