Class: LedgerSync::Domains::ConfigurationStore

Inherits:
Object
  • Object
show all
Defined in:
lib/ledger_sync/domains/store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigurationStore

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

#configsObject (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