Sha256: 35768a38d51e787ae15921597fc0ce494997ead94e403b9af2fd39276e1c478e

Contents?: true

Size: 797 Bytes

Versions: 22

Compression:

Stored size: 797 Bytes

Contents

# frozen_string_literal: true

require_relative 'deserializer_type'

module LedgerSync
  module Serialization
    module Type
      class DeserializerReferencesManyType < DeserializerType
        def cast_value(args = {})
          deserializer_attribute = args.fetch(:deserializer_attribute)
          value                  = args.fetch(:value)
          resource               = args.fetch(:resource)

          return if value.nil?

          first_dot = deserializer_attribute.resource_attribute_dot_parts.first.to_sym
          nested_resource = resource.class.resource_attributes[first_dot].type.resource_class.new

          value.map do |one_value|
            deserializer.new.deserialize(hash: one_value, resource: nested_resource)
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ledger_sync-2.6.0 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.5.0 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.4.4 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.3.1 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.2.3 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.2.1 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.2.0 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.0.2 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.0.1 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.0.0 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-2.0.0.pre.1 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.8.1 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.8.0 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.7.0 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.6.0 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.5.2 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.5.1 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.5.0 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.4.4 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb
ledger_sync-1.4.2 lib/ledger_sync/serialization/type/deserializer_references_many_type.rb