Class: ActiveSupport::Callbacks::CallbackChain
  
  
  
Overview
  
  Instance Attribute Summary collapse
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods included from Enumerable
  #as_json, #compact_blank, #exclude?, #excluding, #in_order_of, #including, #index_by, #index_with, #many?, #maximum, #minimum, #pick, #pluck, #sole, #sum
  
  
  
  
  
  
  Constructor Details
  
    
  
  
    #initialize(name, config)  ⇒ CallbackChain 
  
  
  
  
    
Returns a new instance of CallbackChain.
   
 
  
  
    
      
608
609
610
611
612
613
614
615
616
617 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 608
def initialize(name, config)
  @name = name
  @config = {
    scope: [:kind],
    terminator: default_terminator
  }.merge!(config)
  @chain = []
  @callbacks = nil
  @mutex = Mutex.new
end
     | 
  
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    
Returns the value of attribute config.
   
 
  
  
    
      
606
607
608 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 606
def config
  @config
end 
     | 
  
 
    
      
      
      
  
  
    
Returns the value of attribute name.
   
 
  
  
    
      
606
607
608 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 606
def name
  @name
end 
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #append(*callbacks)  ⇒ Object 
  
  
  
  
    
      
654
655
656 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 654
def append(*callbacks)
  callbacks.each { |c| append_one(c) }
end
     | 
  
 
    
      
  
  
    
      
633
634
635
636
637 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 633
def clear
  @callbacks = nil
  @chain.clear
  self
end 
     | 
  
 
    
      
  
  
    
      
645
646
647
648
649
650
651
652 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 645
def compile
  @callbacks || @mutex.synchronize do
    final_sequence = CallbackSequence.new
    @callbacks ||= @chain.reverse.inject(final_sequence) do |callback_sequence, callback|
      callback.apply callback_sequence
    end
  end
end
     | 
  
 
    
      
  
  
    #delete(o)  ⇒ Object 
  
  
  
  
    
      
628
629
630
631 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 628
def delete(o)
  @callbacks = nil
  @chain.delete(o)
end 
     | 
  
 
    
      
  
  
    #each(&block)  ⇒ Object 
  
  
  
  
    
      
619 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 619
def each(&block); @chain.each(&block); end 
     | 
  
 
    
      
  
  
    #empty?  ⇒ Boolean 
  
  
  
  
    
      
621 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 621
def empty?;       @chain.empty?; end 
     | 
  
 
    
      
  
  
    
      
620 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 620
def index(o);     @chain.index(o); end 
     | 
  
 
    
      
  
  
    #initialize_copy(other)  ⇒ Object 
  
  
  
  
    
      
639
640
641
642
643 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 639
def initialize_copy(other)
  @callbacks = nil
  @chain     = other.chain.dup
  @mutex     = Mutex.new
end 
     | 
  
 
    
      
  
  
    #insert(index, o)  ⇒ Object 
  
  
  
  
    
      
623
624
625
626 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 623
def insert(index, o)
  @callbacks = nil
  @chain.insert(index, o)
end 
     | 
  
 
    
      
  
  
    #prepend(*callbacks)  ⇒ Object 
  
  
  
  
    
      
658
659
660 
     | 
    
      # File 'lib/active_support/callbacks.rb', line 658
def prepend(*callbacks)
  callbacks.each { |c| prepend_one(c) }
end
     |