Class: LedgerSync::AdaptorConfigurationStore
- Inherits:
-
Object
- Object
- LedgerSync::AdaptorConfigurationStore
- Includes:
- Enumerable
- Defined in:
- lib/ledger_sync/adaptor_configuration_store.rb
Instance Attribute Summary collapse
-
#configs ⇒ Object
readonly
Returns the value of attribute configs.
Instance Method Summary collapse
- #add_alias(adaptor_key, existing_config) ⇒ Object
- #config_from_klass(klass:) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ AdaptorConfigurationStore
constructor
A new instance of AdaptorConfigurationStore.
- #register_adaptor(adaptor_key) ⇒ Object
Constructor Details
#initialize ⇒ AdaptorConfigurationStore
Returns a new instance of AdaptorConfigurationStore.
7 8 9 10 11 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 7 def initialize @keys = [] @configs = {} @klass_configs = {} end |
Instance Attribute Details
#configs ⇒ Object (readonly)
Returns the value of attribute configs.
5 6 7 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 5 def configs @configs end |
Instance Method Details
#add_alias(adaptor_key, existing_config) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 13 def add_alias(adaptor_key, existing_config) if respond_to?(adaptor_key) raise LedgerSync::ConfigurationError, "Alias already taken: #{adaptor_key}" if send(adaptor_key) != existing_config return end instance_methods_for(adaptor_key, existing_config) end |
#config_from_klass(klass:) ⇒ Object
23 24 25 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 23 def config_from_klass(klass:) @klass_configs.fetch(klass) end |
#each ⇒ Object
27 28 29 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 27 def each configs.each { |k, v| yield(k, v) } end |
#register_adaptor(adaptor_key) ⇒ Object
31 32 33 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 31 def register_adaptor(adaptor_key) instance_methods_for(adaptor_key) end |