Class: Ductr::Registry
- Inherits:
-
Object
- Object
- Ductr::Registry
- Extended by:
- Forwardable
- Defined in:
- lib/ductr/registry.rb
Overview
The registry pattern to store adapters, controls and triggers.
Instance Method Summary collapse
-
#add(item, as:) ⇒ void
Allow to add one class into the registry.
-
#find(type) ⇒ Class<Adapter, ETL::Control, Trigger>
Find an adapter, control or trigger based on its type.
-
#initialize(name) ⇒ Registry
constructor
Initialize the registry as an empty hash with the given name.
-
#values ⇒ Array<Class<Adapter, ETL::Control, Trigger>>
Get all registered adapters, controls or triggers.
Constructor Details
#initialize(name) ⇒ Registry
Initialize the registry as an empty hash with the given name.
24 25 26 27 |
# File 'lib/ductr/registry.rb', line 24 def initialize(name) @name = name @items = {} end |
Instance Method Details
#add(item, as:) ⇒ void
This method returns an undefined value.
Allow to add one class into the registry.
37 38 39 |
# File 'lib/ductr/registry.rb', line 37 def add(item, as:) @items[as.to_sym] = item end |
#find(type) ⇒ Class<Adapter, ETL::Control, Trigger>
Find an adapter, control or trigger based on its type.
49 50 51 52 53 |
# File 'lib/ductr/registry.rb', line 49 def find(type) @items.fetch(type.to_sym) do raise NotFoundInRegistryError, "The #{@name} of type \"#{type}\" does not exist" end end |
#values ⇒ Array<Class<Adapter, ETL::Control, Trigger>>
Get all registered adapters, controls or triggers.
17 |
# File 'lib/ductr/registry.rb', line 17 def_delegators :@items, :values |