class ActiveSupport::Callbacks::Callback

:nodoc:#

def self.build(chain, filter, kind, options)

:nodoc:#
def self.build(chain, filter, kind, options)
  if filter.is_a?(String)
    raise ArgumentError, <<-MSG.squish
      Passing string to define a callback is not supported. See the `.set_callback`
      documentation to see supported values.
    MSG
  end
  new chain.name, filter, kind, options, chain.config
end

def apply(callback_sequence)

Wraps code with filter
def apply(callback_sequence)
  user_conditions = conditions_lambdas
  user_callback = CallTemplate.build(@filter, self)
  case kind
  when :before
    Filters::Before.build(callback_sequence, user_callback.make_lambda, user_conditions, chain_config, @filter, name)
  when :after
    Filters::After.build(callback_sequence, user_callback.make_lambda, user_conditions, chain_config)
  when :around
    callback_sequence.around(user_callback, user_conditions)
  end
end

def check_conditionals(conditionals)

def check_conditionals(conditionals)
  return EMPTY_ARRAY if conditionals.blank?
  conditionals = Array(conditionals)
  if conditionals.any?(String)
    raise ArgumentError, <<-MSG.squish
      Passing string to be evaluated in :if and :unless conditional
      options is not supported. Pass a symbol for an instance method,
      or a lambda, proc or block, instead.
    MSG
  end
  conditionals.freeze
end

def conditions_lambdas

def conditions_lambdas
  @if.map { |c| CallTemplate.build(c, self).make_lambda } +
    @unless.map { |c| CallTemplate.build(c, self).inverted_lambda }
end

def current_scopes

def current_scopes
  Array(chain_config[:scope]).map { |s| public_send(s) }
end

def duplicates?(other)

def duplicates?(other)
  case @filter
  when Symbol
    matches?(other.kind, other.filter)
  else
    false
  end
end

def initialize(name, filter, kind, options, chain_config)

def initialize(name, filter, kind, options, chain_config)
  @chain_config = chain_config
  @name    = name
  @kind    = kind
  @filter  = filter
  @if      = check_conditionals(options[:if])
  @unless  = check_conditionals(options[:unless])
end

def matches?(_kind, _filter)

def matches?(_kind, _filter)
  @kind == _kind && filter == _filter
end

def merge_conditional_options(chain, if_option:, unless_option:)

def merge_conditional_options(chain, if_option:, unless_option:)
  options = {
    if: @if.dup,
    unless: @unless.dup
  }
  options[:if].concat     Array(unless_option)
  options[:unless].concat Array(if_option)
  self.class.build chain, @filter, @kind, options
end