Module: LedgerSync::Ledgers::Mixins::InferConfigMixin::ClassMethods

Defined in:
lib/ledger_sync/ledgers/mixins/infer_config_mixin.rb

Instance Method Summary collapse

Instance Method Details

#inferred_configObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ledger_sync/ledgers/mixins/infer_config_mixin.rb', line 8

def inferred_config
  return if name.nil?

  @inferred_config ||= begin
    name_parts = name.split('::')
    name_parts_length = name_parts.count

    config = nil

    name_parts_length.times do |i|
      config = LedgerSync.ledgers.config_from_base_module(
        base_module: Object.const_get(
          name_parts[0..(name_parts_length - 1 - i)].join('::')
        )
      )
      break if config.present?
    end

    config
  end
end