module RSpec::Core::Hooks

def after(scope=:each, options={}, &block)

def after(scope=:each, options={}, &block)
  hooks[:after][scope] << AfterHook.new(options, block)
end

def around(scope=:each, options={}, &block)

def around(scope=:each, options={}, &block)
  hooks[:around][scope] << AroundHook.new(options, block)
end

def before(scope=:each, options={}, &block)

def before(scope=:each, options={}, &block)
  hooks[:before][scope] << BeforeHook.new(options, block)
end

def find_hook(hook, scope, group)

def find_hook(hook, scope, group)
  hooks[hook][scope].find_hooks_for(group)
end

def hooks

def hooks
  @hooks ||= {
    :around => { :each => AroundHooks.new },
    :before => { :each => BeforeHooks.new, :all => BeforeHooks.new, :suite => BeforeHooks.new },
    :after => { :each => AfterHooks.new, :all => AfterHooks.new, :suite => AfterHooks.new }
  }
end

def run_hook(hook, scope, example=nil)

example. If no example is provided, just calls the hook directly.
Runs all of the blocks stored with the hook in the context of the
def run_hook(hook, scope, example=nil)
  hooks[hook][scope].run_all(example)
end

def run_hook!(hook, scope, example)

ensuring that they will only be run once.
Just like run_hook, except it removes the blocks as it evalutes them,
def run_hook!(hook, scope, example)
  hooks[hook][scope].run_all!(example)
end

def run_hook_filtered(hook, scope, group, example)

def run_hook_filtered(hook, scope, group, example)
  find_hook(hook, scope, group).run_all(example)
end