Module: Specwrk::Hooks

Defined in:
lib/specwrk/hooks.rb

Class Method Summary collapse

Class Method Details

.load_file(file) ⇒ Object



18
19
20
# File 'lib/specwrk/hooks.rb', line 18

def load_file(file)
  Kernel.load(file) if file && File.file?(file)
end

.register(name, &block) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
# File 'lib/specwrk/hooks.rb', line 6

def register(name, &block)
  raise ArgumentError, "a block is required" unless block

  hooks[name] << block
  block
end

.reset!Object



22
23
24
# File 'lib/specwrk/hooks.rb', line 22

def reset!
  @hooks = nil
end

.run(name, *objects) ⇒ Object



13
14
15
16
# File 'lib/specwrk/hooks.rb', line 13

def run(name, *objects)
  hooks.fetch(name, []).dup.each { |hook| hook.call(*objects) }
  nil
end