Class: ActiveSupport::Callbacks::CallbackChain
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
::Enumerable
|
|
Inherits: | Object |
Defined in: | activesupport/lib/active_support/callbacks.rb |
Overview
An Array with a compile method.
Class Method Summary
- .new(name, config) ⇒ CallbackChain constructor
Instance Attribute Summary
- #config readonly
- #empty? ⇒ Boolean readonly
- #name readonly
::Enumerable - Included
#many? | Returns |
Instance Method Summary
- #append(*callbacks)
- #clear
- #compile
- #delete(o)
- #each(&block)
- #index(o)
- #initialize_copy(other)
- #insert(index, o)
- #prepend(*callbacks)
::Enumerable - Included
Constructor Details
.new(name, config) ⇒ CallbackChain
Instance Attribute Details
#config (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 515
attr_reader :name, :config
#empty? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'activesupport/lib/active_support/callbacks.rb', line 529
def empty?; @chain.empty?; end
#name (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 515
attr_reader :name, :config
Instance Method Details
#append(*callbacks)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 562
def append(*callbacks) callbacks.each { |c| append_one(c) } end
#clear
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 541
def clear @callbacks = nil @chain.clear self end
#compile
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 553
def compile @callbacks || @mutex.synchronize do final_sequence = CallbackSequence.new { |env| Filters::ENDING.call(env) } @callbacks ||= @chain.reverse.inject(final_sequence) do |callback_sequence, callback| callback.apply callback_sequence end end end
#delete(o)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 536
def delete(o) @callbacks = nil @chain.delete(o) end
#each(&block)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 527
def each(&block); @chain.each(&block); end
#index(o)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 528
def index(o); @chain.index(o); end
#initialize_copy(other)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 547
def initialize_copy(other) @callbacks = nil @chain = other.chain.dup @mutex = Mutex.new end
#insert(index, o)
[ GitHub ]#prepend(*callbacks)
[ GitHub ]# File 'activesupport/lib/active_support/callbacks.rb', line 566
def prepend(*callbacks) callbacks.each { |c| prepend_one(c) } end