class ActiveSupport::Callbacks::CallbackChain

:nodoc:

def append(*callbacks)

def append(*callbacks)
  callbacks.each { |c| append_one(c) }
end

def append_one(callback)

def append_one(callback)
  @all_callbacks = nil
  @single_callbacks.clear
  remove_duplicates(callback)
  @chain.push(callback)
end

def clear

def clear
  @all_callbacks = nil
  @single_callbacks.clear
  @chain.clear
  self
end

def compile(type)

def compile(type)
  if type.nil?
    @all_callbacks || @mutex.synchronize do
      final_sequence = CallbackSequence.new
      @all_callbacks ||= @chain.reverse.inject(final_sequence) do |callback_sequence, callback|
        callback.apply(callback_sequence)
      end
    end
  else
    @single_callbacks[type] || @mutex.synchronize do
      final_sequence = CallbackSequence.new
      @single_callbacks[type] ||= @chain.reverse.inject(final_sequence) do |callback_sequence, callback|
        type == callback.kind ? callback.apply(callback_sequence) : callback_sequence
      end
    end
  end
end

def default_terminator

def default_terminator
  Proc.new do |target, result_lambda|
    terminate = true
    catch(:abort) do
      result_lambda.call
      terminate = false
    end
    terminate
  end
end

def delete(o)

def delete(o)
  @all_callbacks = nil
  @single_callbacks.clear
  @chain.delete(o)
end

def each(&block); @chain.each(&block); end

def each(&block); @chain.each(&block); end

def empty?; @chain.empty?; end

def empty?;       @chain.empty?; end

def index(o); @chain.index(o); end

def index(o);     @chain.index(o); end

def initialize(name, config)

def initialize(name, config)
  @name = name
  @config = {
    scope: [:kind],
    terminator: default_terminator
  }.merge!(config)
  @chain = []
  @all_callbacks = nil
  @single_callbacks = {}
  @mutex = Mutex.new
end

def initialize_copy(other)

def initialize_copy(other)
  @all_callbacks = nil
  @single_callbacks = {}
  @chain     = other.chain.dup
  @mutex     = Mutex.new
end

def insert(index, o)

def insert(index, o)
  @all_callbacks = nil
  @single_callbacks.clear
  @chain.insert(index, o)
end

def prepend(*callbacks)

def prepend(*callbacks)
  callbacks.each { |c| prepend_one(c) }
end

def prepend_one(callback)

def prepend_one(callback)
  @all_callbacks = nil
  @single_callbacks.clear
  remove_duplicates(callback)
  @chain.unshift(callback)
end

def remove_duplicates(callback)

def remove_duplicates(callback)
  @all_callbacks = nil
  @single_callbacks.clear
  @chain.delete_if { |c| callback.duplicates?(c) }
end