mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #42173 from okuramasafumi/improve-docs-of-activesupport-callbacks
[ci-skip] Improve doc for `ActiveSupport::Callbacks.skip_callback`
This commit is contained in:
commit
908ccc194e
1 changed files with 24 additions and 2 deletions
|
@ -676,10 +676,32 @@ module ActiveSupport
|
||||||
# <tt>:unless</tt> options may be passed in order to control when the
|
# <tt>:unless</tt> options may be passed in order to control when the
|
||||||
# callback is skipped.
|
# callback is skipped.
|
||||||
#
|
#
|
||||||
# class Writer < Person
|
# class Writer < PersonRecord
|
||||||
# skip_callback :validate, :before, :check_membership, if: -> { age > 18 }
|
# attr_accessor :age
|
||||||
|
# skip_callback :save, :before, :saving_message, if: -> { age > 18 }
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
|
# When if option returns true, callback is skipped.
|
||||||
|
#
|
||||||
|
# writer = Writer.new
|
||||||
|
# writer.age = 20
|
||||||
|
# writer.save
|
||||||
|
#
|
||||||
|
# Output:
|
||||||
|
# - save
|
||||||
|
# saved
|
||||||
|
#
|
||||||
|
# When if option returns false, callback is NOT skipped.
|
||||||
|
#
|
||||||
|
# young_writer = Writer.new
|
||||||
|
# young_writer.age = 17
|
||||||
|
# young_writer.save
|
||||||
|
#
|
||||||
|
# Output:
|
||||||
|
# saving...
|
||||||
|
# - save
|
||||||
|
# saved
|
||||||
|
#
|
||||||
# An <tt>ArgumentError</tt> will be raised if the callback has not
|
# An <tt>ArgumentError</tt> will be raised if the callback has not
|
||||||
# already been set (unless the <tt>:raise</tt> option is set to <tt>false</tt>).
|
# already been set (unless the <tt>:raise</tt> option is set to <tt>false</tt>).
|
||||||
def skip_callback(name, *filter_list, &block)
|
def skip_callback(name, *filter_list, &block)
|
||||||
|
|
Loading…
Reference in a new issue