Method: Gurke::Configuration::HookSet#run

Defined in:
lib/gurke/configuration.rb

#run(context, world, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/gurke/configuration.rb', line 127

def run(context, world, &block)
  ctx = Context.new context, block
  @before.each{|hook| hook.run world, ctx }
  @around.reduce Context.new(context, block) do |c, e|
    Context.new(context, ->{ e.run world, c })
  end.call
ensure
  @after.each do |hook|
    begin
      hook.run world, ctx
    rescue => e
      warn "Rescued error in after hook: #{e}\n#{e.backtrace.join("\n")}"
    end
  end
end