Sha256: 8b2aadb7502339fa59350159eec8d27e7737c039c14019d8e6338782251cfae9

Contents?: true

Size: 621 Bytes

Versions: 4

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Ledgers
    module Mixins
      module InferClientMixin
        module ClassMethods
          def inferred_client_class
            @inferred_client_class ||= begin
              return if name.nil?

              parts = name.split('::')
              return unless parts.include?('Ledgers')

              LedgerSync::Ledgers.const_get(
                parts[parts.index('Ledgers') + 1]
              )::Client
            end
          end
        end

        def self.included(base)
          base.extend ClassMethods
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ledger_sync-1.4.4 lib/ledger_sync/ledgers/mixins/infer_client_mixin.rb
ledger_sync-1.4.2 lib/ledger_sync/ledgers/mixins/infer_client_mixin.rb
ledger_sync-1.4.1 lib/ledger_sync/ledgers/mixins/infer_client_mixin.rb
ledger_sync-1.4.0 lib/ledger_sync/ledgers/mixins/infer_client_mixin.rb