Sha256: 1c375e3db43ef36eebb5714b804ec2e62acb9ab919ecc19c2888e7c782f6517f

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Adaptors
    module LedgerSerializerType
      class ReferencesManyType < ValueType
        def convert_from_ledger(resource_class: nil, serializer:, value:)
          resource_class ||= serializer._inferred_resource_class
          return [] if value.nil?

          value.map do |one_value|
            serializer.new(resource: resource_class.new).deserialize(hash: one_value)
          end
        end

        def convert_from_local(serializer:, value:)
          value.map do |one_value|
            serializer.new(resource: one_value).to_ledger_hash
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ledger_sync-1.1.3 lib/ledger_sync/adaptors/ledger_serializer_type/references_many_type.rb
ledger_sync-1.1.2 lib/ledger_sync/adaptors/ledger_serializer_type/references_many_type.rb