module RSpec::Core::Hooks::RegistersGlobals

def process host, globals, position, scope

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

def register_globals host, globals

def register_globals host, globals
  [:before, :after, :around].each do |position|
    process host, globals, position, :each
    next if position == :around # no around(:all) hooks
    process host, globals, position, :all
  end
end