Sha256: a9245409ad94e617f6bd0b7ef0601a120331af373f031aff2db56c161caf2508

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 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 ||= begin
              "#{inferred_resource_class.resource_module_str}::SearcherDeserializer"
            end
          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

1 entries across 1 versions & 1 rubygems

Version Path
ledger_sync-1.4.4 lib/ledger_sync/ledgers/mixins/infer_serializer_mixin.rb