Class: ActiveSupport::Callbacks::CallbackSequence
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
- .new(&call) ⇒ CallbackSequence constructor
Instance Method Summary
Constructor Details
.new(&call) ⇒ CallbackSequence
Instance Method Details
#after(&after)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 490
def after(&after) @after.push(after) self end
#around(&around)
[ GitHub ]#before(&before)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 485
def before(&before) @before.unshift(before) self end
#call(*args)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 503
def call(*args) @before.each { |b| b.call(*args) } value = @call.call(*args) @after.each { |a| a.call(*args) } value end