Module: Webspicy::Support::Hooks

Included in:
Object
Defined in:
lib/webspicy/support/hooks.rb

Defined Under Namespace

Classes: Object

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(config) ⇒ Object



13
14
15
# File 'lib/webspicy/support/hooks.rb', line 13

def self.for(config)
  Object.new(config)
end

Instance Method Details

#fire_after_all(*args, &bl) ⇒ Object



57
58
59
60
61
# 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) ⇒ Object



45
46
47
48
49
# 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) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# 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) ⇒ Object



51
52
53
54
55
# 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) ⇒ Object



39
40
41
42
43
# 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