Class: ActiveSupport::Callbacks::CallbackSequence
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activesupport/lib/active_support/callbacks.rb |
Overview
Execute before and after filters in a sequence instead of chaining them with nested lambda calls, see: github.com/rails/rails/issues/18011
Class Method Summary
Instance Attribute Summary
- #final? ⇒ Boolean readonly
- #nested readonly
Instance Method Summary
Constructor Details
.new(nested = nil, call_template = nil, user_conditions = nil) ⇒ CallbackSequence
Instance Attribute Details
#final? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'activesupport/lib/active_support/callbacks.rb', line 549
def final? !@call_template end
#nested (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 547
attr_reader :nested
Instance Method Details
#after(after)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 533
def after(after) @after ||= [] @after.push(after) self end
#around(call_template, user_conditions)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 539
def around(call_template, user_conditions) CallbackSequence.new(self, call_template, user_conditions) end
#before(before)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 527
def before(before) @before ||= [] @before.unshift(before) self end
#expand_call_template(arg, block)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 553
def (arg, block) @call_template. (arg.target, arg.value, block) end
#invoke_after(arg)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 561
def invoke_after(arg) @after&.each { |a| a.call(arg) } end
#invoke_before(arg)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 557
def invoke_before(arg) @before&.each { |b| b.call(arg) } end
#skip?(arg) ⇒ Boolean
# File 'activesupport/lib/active_support/callbacks.rb', line 543
def skip?(arg) arg.halted || !@user_conditions.all? { |c| c.call(arg.target, arg.value) } end