Sha256: 8f76a1fcb7b0b6f7b18e1141ad061466aa85abcbd0a58d558a43e32da6b33c6b

Contents?: true

Size: 812 Bytes

Versions: 17

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Domains
    class ConfigurationStore
      attr_reader :configs

      def initialize
        @configs = {}
      end

      def register_domain(config:)
        @configs[config.root_key] = config
      end

      def module_for(domain:)
        @configs[domain]&.base_module
      end

      def domain_for(base_module:)
        config = @configs.values.find { |c| c.base_module == base_module }
        config ||= @configs[:main]

        config.root_key
      end
    end

    class Configuration
      attr_accessor :name
      attr_reader :root_key, :base_module

      def initialize(root_key, base_module:)
        @root_key = root_key.to_sym
        @name = root_key.to_s.capitalize
        @base_module = base_module
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ledger_sync-domains-1.2.1 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.2.0 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.1.4 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.1.3 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.1.1 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.1.0 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.5 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.4 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.3 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.2 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.1 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.0 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.0.rc10 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.0.rc9 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.0.rc8 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.0.rc7 lib/ledger_sync/domains/store.rb
ledger_sync-domains-1.0.0.rc6 lib/ledger_sync/domains/store.rb