Class: Gurke::Configuration::HookSet Private
- Inherits:
-
Object
- Object
- Gurke::Configuration::HookSet
- 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
- #append(set, hook) ⇒ Object private
-
#initialize ⇒ HookSet
constructor
private
A new instance of HookSet.
- #run(world, &block) ⇒ Object private
Constructor Details
#initialize ⇒ HookSet
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.
92 93 94 95 96 |
# File 'lib/gurke/configuration.rb', line 92 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.
98 99 100 101 102 103 104 105 |
# File 'lib/gurke/configuration.rb', line 98 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.
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/gurke/configuration.rb', line 107 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 |