Class: Evilution::Hooks::Loader Private
- Inherits:
-
Object
- Object
- Evilution::Hooks::Loader
- Defined in:
- lib/evilution/hooks/loader.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.
Class Method Summary collapse
Class Method Details
.call(registry, config_hooks = nil) ⇒ 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.
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 |