Class: Dependabot::ErrorDetails

Inherits:
T::ImmutableStruct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/error_details.rb

Constant Summary collapse

DetailHash =
T.type_alias { T::Hash[T.any(String, Symbol), T.anything] }
Detail =
T.type_alias { T.any(String, DetailHash) }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object

Raises:

  • (TypeError)


17
18
19
20
21
22
23
24
25
# File 'lib/dependabot/error_details.rb', line 17

def self.from_hash(hash)
  raw_type = T.cast(hash[:"error-type"], Object)
  raise TypeError, "error-type must be a string" unless raw_type.is_a?(String)

  new(
    error_type: raw_type,
    error_detail: parse_detail(T.cast(hash[:"error-detail"], T.nilable(Object)))
  )
end

Instance Method Details

#to_hObject



28
29
30
31
32
# File 'lib/dependabot/error_details.rb', line 28

def to_h
  result = T.let({ "error-type": error_type }, T::Hash[Symbol, Object])
  result[:"error-detail"] = error_detail if error_detail
  result
end