Class: Dependabot::Credential

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, T::Sig
Defined in:
lib/dependabot/credential.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credential) ⇒ Credential

Returns a new instance of Credential.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dependabot/credential.rb', line 15

def initialize(credential)
  @replaces_base = T.let(credential["replaces-base"] == true, T::Boolean)
  credential.delete("replaces-base")

  raw_scope = credential.delete("scope")
  @scope = T.let(
    case raw_scope
    when String then [raw_scope]
    when Array then raw_scope
    end,
    T.nilable(T::Array[String])
  )

  @credential = T.let(T.unsafe(credential), T::Hash[String, String])
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



37
38
39
# File 'lib/dependabot/credential.rb', line 37

def scope
  @scope
end

Instance Method Details

#[](key) ⇒ Object



40
41
42
# File 'lib/dependabot/credential.rb', line 40

def [](key)
  @credential[key]
end

#merge(other) ⇒ Object



45
46
47
# File 'lib/dependabot/credential.rb', line 45

def merge(other)
  Credential.new(@credential.merge(other.to_h))
end

#replaces_base?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/dependabot/credential.rb', line 32

def replaces_base?
  @replaces_base
end

#to_hObject



50
51
52
# File 'lib/dependabot/credential.rb', line 50

def to_h
  @credential
end