class RSpec::Core::Hooks::HookCollections

@private

def [](key)

def [](key)
  @data[key]
end

def after_context_hooks_for(group)

def after_context_hooks_for(group)
  GroupHookCollection.new(self[:after][:context]).for(group)
end

def after_example_hooks_for(example)

def after_example_hooks_for(example)
  HookCollection.new(FlatMap.flat_map(@owner.parent_groups) do |a|
    a.hooks[:after][:example]
  end).for(example)
end

def around_example_hooks_for(example, initial_procsy=nil)

def around_example_hooks_for(example, initial_procsy=nil)
  AroundHookCollection.new(FlatMap.flat_map(@owner.parent_groups) do |a|
    a.hooks[:around][:example]
  end).for(example, initial_procsy)
end

def before_context_hooks_for(group)

def before_context_hooks_for(group)
  GroupHookCollection.new(self[:before][:context]).for(group)
end

def before_example_hooks_for(example)

def before_example_hooks_for(example)
  HookCollection.new(FlatMap.flat_map(@owner.parent_groups.reverse) do |a|
    a.hooks[:before][:example]
  end).for(example)
end

def extract_scope_from(args)

def extract_scope_from(args)
  if known_scope?(args.first)
    normalized_scope_for(args.shift)
  elsif args.any? { |a| a.is_a?(Symbol) }
    error_message = "You must explicitly give a scope (#{SCOPES.join(", ")}) or scope alias (#{SCOPE_ALIASES.keys.join(", ")}) when using symbols as metadata for a hook."
    raise ArgumentError.new error_message
  else
    :example
  end
end

def find_hook(hook, scope, example_or_group, initial_procsy)

def find_hook(hook, scope, example_or_group, initial_procsy)
  case [hook, scope]
  when [:before, :context]
    before_context_hooks_for(example_or_group)
  when [:after, :context]
    after_context_hooks_for(example_or_group)
  when [:around, :example]
    around_example_hooks_for(example_or_group, initial_procsy)
  when [:before, :example]
    before_example_hooks_for(example_or_group)
  when [:after, :example]
    after_example_hooks_for(example_or_group)
  when [:before, :suite], [:after, :suite]
    self[hook][:suite].with(example_or_group)
  end
end

def initialize(owner, data)

def initialize(owner, data)
  @owner = owner
  @data  = data
end

def known_scope?(scope)

Other tags:
    Api: - private
def known_scope?(scope)
  SCOPES.include?(scope) || SCOPE_ALIASES.keys.include?(scope)
end

def normalized_scope_for(scope)

Other tags:
    Api: - private
def normalized_scope_for(scope)
  SCOPE_ALIASES[scope] || scope
end

def process(host, globals, position, scope)

def process(host, globals, position, scope)
  globals[position][scope].each do |hook|
    next unless scope == :example || hook.options_apply?(host)
    next if host.parent_groups.any? { |a| a.hooks[position][scope].include?(hook) }
    self[position][scope] << hook
  end
end

def register(prepend_or_append, hook, *args, &block)

def register(prepend_or_append, hook, *args, &block)
  scope, options = scope_and_options_from(*args)
  self[hook][scope].__send__(prepend_or_append, HOOK_TYPES[hook][scope].new(block, options))
end

def register_globals(host, globals)

def register_globals(host, globals)
  process(host, globals, :before, :example)
  process(host, globals, :after,  :example)
  process(host, globals, :around, :example)
  process(host, globals, :before, :context)
  process(host, globals, :after,  :context)
end

def run(hook, scope, example_or_group, initial_procsy=nil)

Other tags:
    Private: -
def run(hook, scope, example_or_group, initial_procsy=nil)
  return if RSpec.configuration.dry_run?
  find_hook(hook, scope, example_or_group, initial_procsy).run
end

def scope_and_options_from(*args)

def scope_and_options_from(*args)
  scope = extract_scope_from(args)
  meta  = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
  return scope, meta
end