forked from dependabot/dependabot-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
credential.rb
41 lines (33 loc) · 1002 Bytes
/
credential.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# typed: strict
# frozen_string_literal: true
require "sorbet-runtime"
require "forwardable"
module Dependabot
class Credential
extend T::Sig
extend Forwardable
def_delegators :@credential, :fetch, :keys, :[]=, :delete, :slice, :values, :entries
sig { params(credential: T::Hash[String, T.any(T::Boolean, String)]).void }
def initialize(credential)
@replaces_base = T.let(credential["replaces-base"] == true, T::Boolean)
credential.delete("replaces-base")
@credential = T.let(T.unsafe(credential), T::Hash[String, String])
end
sig { returns(T::Boolean) }
def replaces_base?
@replaces_base
end
sig { params(key: String).returns(T.nilable(String)) }
def [](key)
@credential[key]
end
sig { params(other: Credential).returns(Credential) }
def merge(other)
Credential.new(@credential.merge(other.to_h))
end
sig { returns(T::Hash[String, String]) }
def to_h
@credential
end
end
end