1
0
Fork 0
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:
Ryuta Kamizono 2021-05-08 18:39:29 +09:00 committed by GitHub
commit 908ccc194e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -676,10 +676,32 @@ module ActiveSupport
# <tt>:unless</tt> options may be passed in order to control when the
# callback is skipped.
#
# class Writer < Person
# skip_callback :validate, :before, :check_membership, if: -> { age > 18 }
# class Writer < PersonRecord
# attr_accessor :age
# skip_callback :save, :before, :saving_message, if: -> { age > 18 }
# 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
# already been set (unless the <tt>:raise</tt> option is set to <tt>false</tt>).
def skip_callback(name, *filter_list, &block)