Class: Gurke::Configuration::HookSet Private

Inherits:
Object
  • Object
show all
Defined in:
lib/gurke/configuration.rb

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

Instance Method Summary collapse

Constructor Details

#initializeHookSet

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.

Returns a new instance of HookSet.



110
111
112
113
114
# File 'lib/gurke/configuration.rb', line 110

def initialize
  @before = []
  @after  = []
  @around = []
end

Instance Method Details

#append(set, hook) ⇒ 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.



116
117
118
119
120
121
122
123
# File 'lib/gurke/configuration.rb', line 116

def append(set, hook)
  case set
    when :before then @before << hook
    when :after  then @after << hook
    when :around then @around << hook
    else raise ArgumentError.new "Unknown hook set: #{set}"
  end
end

#run(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.



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/gurke/configuration.rb', line 125

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