Sha256: af364b05f1e151eba5d02210d6c6b6daeda06ce7b79f8790ed163f3150647581

Contents?: true

Size: 638 Bytes

Versions: 4

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Util
    class ResourceConverter
      module Type
        class ResourceConverterType < LedgerSync::Type::Value
          attr_reader :resource_converter

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

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

            return if source.nil?

            resource_converter.new.convert(destination: destination, source: source)
          end
        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/util/resource_converter/type/resource_converter_type.rb
ledger_sync-1.4.2 lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb
ledger_sync-1.4.1 lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb
ledger_sync-1.4.0 lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb