Method: ActiveSupport::Callbacks::ClassMethods#skip_callback
- Defined in:
- activesupport/lib/active_support/callbacks.rb
permalink #skip_callback(name, *filter_list, &block) ⇒ Object
Skip a previously set callback. Like set_callback
, :if
or :unless
options may be passed in order to control when the callback is skipped.
class Writer < Person
skip_callback :validate, :before, :check_membership, if: -> { self.age > 18 }
end
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
# File 'activesupport/lib/active_support/callbacks.rb', line 620 def skip_callback(name, *filter_list, &block) type, filters, = normalize_callback_params(filter_list, block) __update_callbacks(name) do |target, chain| filters.each do |filter| filter = chain.find {|c| c.matches?(type, filter) } if filter && .any? new_filter = filter.merge(chain, ) chain.insert(chain.index(filter), new_filter) end chain.delete(filter) end target.set_callbacks name, chain end end |