6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/evilution/hooks/loader.rb', line 6
def self.call(registry, config_hooks = nil)
return registry if config_hooks.nil?
unless config_hooks.is_a?(Hash)
raise Evilution::ConfigError, "hooks must be a mapping of event names to file paths, got #{config_hooks.class}"
end
return registry if config_hooks.empty?
config_hooks.each do |event, paths|
event = event.to_sym
Array(paths).each do |path|
handler = load_hook_file(path)
registry.register(event) { |payload| handler.call(payload) }
end
end
registry
end
|