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.
-
#inflections ⇒ Object
readonly
Returns the value of attribute inflections.
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_config:) ⇒ Object
Constructor Details
#initialize ⇒ AdaptorConfigurationStore
Returns a new instance of AdaptorConfigurationStore.
7 8 9 10 11 12 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 7 def initialize @keys = [] @configs = {} @inflections = [] @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 |
#inflections ⇒ Object (readonly)
Returns the value of attribute inflections.
5 6 7 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 5 def inflections @inflections end |
Instance Method Details
#add_alias(adaptor_key, existing_config) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 14 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: adaptor_key, adaptor_config: existing_config) end |
#config_from_klass(klass:) ⇒ Object
24 25 26 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 24 def config_from_klass(klass:) @klass_configs.fetch(klass) end |
#each ⇒ Object
28 29 30 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 28 def each configs.each { |k, v| yield(k, v) } end |
#register_adaptor(adaptor_config:) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ledger_sync/adaptor_configuration_store.rb', line 32 def register_adaptor(adaptor_config:) _instance_methods_for( adaptor_key: adaptor_config.root_key, adaptor_config: adaptor_config ) end |