Sha256: 965db5c4e9f8ec3f6dc63c32dce6c76a861a66c9bc52ef98328d940b785d08ba

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require_relative 'infer_client_mixin'
require_relative 'infer_resource_class_mixin'

module LedgerSync
  module Ledgers
    module Mixins
      module InferSerializerMixin
        module ClassMethods
          def inferred_deserializer_class
            @inferred_deserializer_class ||= inferred_client_class.base_module.const_get(
              inferred_deserializer_class_name
            )
          end

          def inferred_deserializer_class_name
            @inferred_deserializer_class_name ||= "#{inferred_resource_class.resource_module_str}::Deserializer"
          end

          def inferred_searcher_deserializer_class
            @inferred_searcher_deserializer_class ||= inferred_client_class.base_module.const_get(
              inferred_searcher_deserializer_class_name
            )
          end

          def inferred_searcher_deserializer_class_name
            @inferred_searcher_deserializer_class_name ||= "#{inferred_resource_class.resource_module_str}::SearcherDeserializer"
          end

          def inferred_serializer_class
            @inferred_serializer_class ||= begin
              inferred_client_class.base_module.const_get(
                inferred_serializer_class_name
              )
            end
          end

          def inferred_serializer_class_name
            @inferred_serializer_class_name ||= "#{inferred_resource_class.resource_module_str}::Serializer"
          end
        end

        def self.included(base)
          base.include InferClientMixin
          base.include InferResourceClassMixin
          base.extend ClassMethods
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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