Sha256: f49b9c3de4c4eb52ef6c7903d249da4ccc727880fced8f53aa2b67b3ab810916

Contents?: true

Size: 465 Bytes

Versions: 4

Compression:

Stored size: 465 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Serialization
    module Type
      class SerializerType < LedgerSync::Type::Value
        attr_reader :serializer

        def initialize(args = {})
          @serializer = args.fetch(:serializer)
        end

        def cast_value(args = {})
          value = args.fetch(:value)

          return if value.nil?

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ledger_sync-1.4.4 lib/ledger_sync/serialization/type/serializer_type.rb
ledger_sync-1.4.2 lib/ledger_sync/serialization/type/serializer_type.rb
ledger_sync-1.4.1 lib/ledger_sync/serialization/type/serializer_type.rb
ledger_sync-1.4.0 lib/ledger_sync/serialization/type/serializer_type.rb