module Webspicy::Support::Hooks
Public Class Methods
for(config)
click to toggle source
# File lib/webspicy/support/hooks.rb, line 13 def self.for(config) Object.new(config) end
Public Instance Methods
fire_after_all(*args, &bl)
click to toggle source
# File lib/webspicy/support/hooks.rb, line 57 def fire_after_all(*args, &bl) config.listeners(:after_all).each do |aeach| aeach.call(*args, &bl) end end
fire_after_each(*args, &bl)
click to toggle source
# File lib/webspicy/support/hooks.rb, line 45 def fire_after_each(*args, &bl) config.listeners(:after_each).each do |aeach| aeach.call(*args, &bl) end end
fire_around(*args, &bl)
click to toggle source
# File lib/webspicy/support/hooks.rb, line 17 def fire_around(*args, &bl) ls = config.listeners(:around_each) if ls.size == 0 bl.call elsif ls.size > 1 _fire_around(ls.first, ls[1..-1], args, &bl) else ls.first.call(*args, &bl) end end
fire_before_all(*args, &bl)
click to toggle source
# File lib/webspicy/support/hooks.rb, line 51 def fire_before_all(*args, &bl) config.listeners(:before_all).each do |beach| beach.call(*args, &bl) end end
fire_before_each(*args, &bl)
click to toggle source
# File lib/webspicy/support/hooks.rb, line 39 def fire_before_each(*args, &bl) config.listeners(:before_each).each do |beach| beach.call(*args, &bl) end end
Private Instance Methods
_fire_around(head, tail, args, &bl)
click to toggle source
# File lib/webspicy/support/hooks.rb, line 28 def _fire_around(head, tail, args, &bl) head.call(*args) do if tail.empty? bl.call else _fire_around(tail.first, tail[1..-1], args, &bl) end end end