Sha256: ffa0b4b56fa05f043cc4a87a06d2a5df0fba403e2e63ba389062c5bdb756d486

Contents?: true

Size: 585 Bytes

Versions: 4

Compression:

Stored size: 585 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Adaptors
    module LedgerSerializerType
      class ReferencesOneType < ValueType
        def convert_from_ledger(resource_class: nil, serializer:, value:)
          return if value.nil?

          resource_class ||= serializer.inferred_resource_class
          serializer.new(resource: resource_class.new).deserialize(hash: value)
        end

        def convert_from_local(serializer:, value:)
          return if value.nil?

          serializer.new(resource: value).to_ledger_hash
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ledger_sync-1.3.5 lib/ledger_sync/adaptors/ledger_serializer_type/references_one_type.rb
ledger_sync-1.3.4 lib/ledger_sync/adaptors/ledger_serializer_type/references_one_type.rb
ledger_sync-1.3.3 lib/ledger_sync/adaptors/ledger_serializer_type/references_one_type.rb
ledger_sync-1.3.2 lib/ledger_sync/adaptors/ledger_serializer_type/references_one_type.rb