Class: LedgerSync::LedgerConfigurationStore

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ledger_sync/ledger_configuration_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLedgerConfigurationStore

Returns a new instance of LedgerConfigurationStore.



9
10
11
12
13
14
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 9

def initialize
  @keys = []
  @configs = {}
  @inflections = []
  @class_configs = {}
end

Instance Attribute Details

#configsObject (readonly)

Returns the value of attribute configs.



7
8
9
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 7

def configs
  @configs
end

#inflectionsObject (readonly)

Returns the value of attribute inflections.



7
8
9
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 7

def inflections
  @inflections
end

Instance Method Details

#add_alias(client_key, existing_config) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 16

def add_alias(client_key, existing_config)
  if respond_to?(client_key)
    if send(client_key) != existing_config
      raise LedgerSync::ConfigurationError, "Alias already taken: #{client_key}"
    end

    return
  end

  _instance_methods_for(client_key: client_key, ledger_config: existing_config)
end

#config_from_class(client_class:) ⇒ Object



28
29
30
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 28

def config_from_class(client_class:)
  @class_configs.fetch(client_class)
end

#eachObject



32
33
34
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 32

def each
  configs.each { |k, v| yield(k, v) }
end

#register_ledger(ledger_config:) ⇒ Object



36
37
38
39
40
41
# File 'lib/ledger_sync/ledger_configuration_store.rb', line 36

def register_ledger(ledger_config:)
  _instance_methods_for(
    client_key: ledger_config.root_key,
    ledger_config: ledger_config
  )
end