Class: LedgerSync::LedgerConfigurationStore
- Inherits:
-
Object
- Object
- LedgerSync::LedgerConfigurationStore
- Includes:
- Enumerable
- Defined in:
- lib/ledger_sync/ledger_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(client_key, existing_config) ⇒ Object
- #config_from_class(client_class:) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ LedgerConfigurationStore
constructor
A new instance of LedgerConfigurationStore.
- #register_ledger(ledger_config:) ⇒ Object
Constructor Details
#initialize ⇒ LedgerConfigurationStore
Returns a new instance of LedgerConfigurationStore.
7 8 9 10 11 12 |
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 7 def initialize @keys = [] @configs = {} @inflections = [] @class_configs = {} end |
Instance Attribute Details
#configs ⇒ Object (readonly)
Returns the value of attribute configs.
5 6 7 |
# File 'lib/ledger_sync/ledger_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/ledger_configuration_store.rb', line 5 def inflections @inflections end |
Instance Method Details
#add_alias(client_key, existing_config) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 14 def add_alias(client_key, existing_config) if respond_to?(client_key) raise LedgerSync::ConfigurationError, "Alias already taken: #{client_key}" if send(client_key) != existing_config return end _instance_methods_for(client_key: client_key, ledger_config: existing_config) end |
#config_from_class(client_class:) ⇒ Object
24 25 26 |
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 24 def config_from_class(client_class:) @class_configs.fetch(client_class) end |
#each ⇒ Object
28 29 30 |
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 28 def each configs.each { |k, v| yield(k, v) } end |
#register_ledger(ledger_config:) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 32 def register_ledger(ledger_config:) _instance_methods_for( client_key: ledger_config.root_key, ledger_config: ledger_config ) end |