Class: LedgerSync::Domains::ConfigurationStore
- Inherits:
-
Object
- Object
- LedgerSync::Domains::ConfigurationStore
- Defined in:
- lib/ledger_sync/domains/store.rb
Instance Attribute Summary collapse
-
#configs ⇒ Object
readonly
Returns the value of attribute configs.
Instance Method Summary collapse
- #domain_for(base_module:) ⇒ Object
-
#initialize ⇒ ConfigurationStore
constructor
A new instance of ConfigurationStore.
- #module_for(domain:) ⇒ Object
- #register_domain(config:) ⇒ Object
Constructor Details
#initialize ⇒ ConfigurationStore
Returns a new instance of ConfigurationStore.
8 9 10 |
# File 'lib/ledger_sync/domains/store.rb', line 8 def initialize @configs = {} end |
Instance Attribute Details
#configs ⇒ Object (readonly)
Returns the value of attribute configs.
6 7 8 |
# File 'lib/ledger_sync/domains/store.rb', line 6 def configs @configs end |
Instance Method Details
#domain_for(base_module:) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ledger_sync/domains/store.rb', line 20 def domain_for(base_module:) config = @configs.values.find { |c| c.base_module == base_module } config ||= @configs[:main] config.root_key end |
#module_for(domain:) ⇒ Object
16 17 18 |
# File 'lib/ledger_sync/domains/store.rb', line 16 def module_for(domain:) @configs[domain]&.base_module end |
#register_domain(config:) ⇒ Object
12 13 14 |
# File 'lib/ledger_sync/domains/store.rb', line 12 def register_domain(config:) @configs[config.root_key] = config end |