Sha256: 2242e875c140a1fb229bb8c74b79a2673949450a411bc4bfa08328fb0a7a6339

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

require_relative '../../utils/hash'

module Datadog
  module Core
    module Telemetry
      module V1
        # Describes attributes for dependency object
        class Dependency
          using Core::Utils::Hash::Refinement

          ERROR_NIL_NAME_MESSAGE = ':name must not be nil'.freeze

          attr_reader \
            :hash,
            :name,
            :version

          # @param name [String] Module name
          # @param version [String] Version of resolved module
          # @param hash [String] Dependency hash, in case `version` is not available
          def initialize(name:, version: nil, hash: nil)
            raise ArgumentError, ERROR_NIL_NAME_MESSAGE if name.nil?
            raise ArgumentError, 'if both :version and :hash exist, use :version only' if version && hash

            @hash = hash
            @name = name
            @version = version
          end

          def to_h
            hash = {
              hash: @hash,
              name: @name,
              version: @version
            }
            hash.compact!
            hash
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ddtrace-1.21.1 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.21.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.20.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.19.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.18.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.17.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.16.2 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.16.1 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.16.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.15.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.14.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.13.1 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.13.0 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.12.1 lib/datadog/core/telemetry/v1/dependency.rb
ddtrace-1.12.0 lib/datadog/core/telemetry/v1/dependency.rb