Module: Archsight::Import::Registry
- Defined in:
- lib/archsight/import/registry.rb
Overview
Registry of import handlers
Handlers register themselves with a name that matches the import/handler annotation. The executor looks up handlers by name to instantiate and execute them.
Class Method Summary collapse
-
.[](name) ⇒ Class?
Look up a handler class by name.
-
.clear! ⇒ Object
Clear all registered handlers (for testing).
-
.handler_for(import_resource) ⇒ Class
Get handler class for an import resource.
-
.handlers ⇒ Array<String>
List all registered handler names.
-
.register(name, handler_class) ⇒ Object
Register a handler class with a name.
Class Method Details
.[](name) ⇒ Class?
Look up a handler class by name
23 24 25 |
# File 'lib/archsight/import/registry.rb', line 23 def [](name) @handlers[name.to_s] end |
.clear! ⇒ Object
Clear all registered handlers (for testing)
47 48 49 |
# File 'lib/archsight/import/registry.rb', line 47 def clear! @handlers = {} end |
.handler_for(import_resource) ⇒ Class
Get handler class for an import resource
31 32 33 34 35 36 37 38 |
# File 'lib/archsight/import/registry.rb', line 31 def handler_for(import_resource) handler_name = import_resource.annotations["import/handler"] handler_class = self[handler_name] raise Archsight::Import::UnknownHandlerError, "Unknown import handler: #{handler_name}" unless handler_class handler_class end |
.handlers ⇒ Array<String>
List all registered handler names
42 43 44 |
# File 'lib/archsight/import/registry.rb', line 42 def handlers @handlers.keys end |
.register(name, handler_class) ⇒ Object
Register a handler class with a name
16 17 18 |
# File 'lib/archsight/import/registry.rb', line 16 def register(name, handler_class) @handlers[name.to_s] = handler_class end |