Class: Aws::Session::Credentials::CredentialFile

Inherits:
Object
  • Object
show all
Includes:
FileProvider::IniFileProvider, ProfileStorage
Defined in:
lib/aws/session/credentials/credential_file.rb

Overview

Holds credentials that are read by AWS SDKs

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ProfileStorage

#print_profiles, #profile, #profiles, #profiles=, #set_profile

Methods included from FileProvider::IniFileProvider

#[], #[]=, #read

Constructor Details

#initialize(options = {}) ⇒ CredentialFile

Returns a new instance of CredentialFile.



11
12
13
# File 'lib/aws/session/credentials/credential_file.rb', line 11

def initialize(options = {})
  @path = File.expand_path(options[:path] || default_path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/aws/session/credentials/credential_file.rb', line 9

def path
  @path
end

Instance Method Details

#default_pathObject



15
16
17
# File 'lib/aws/session/credentials/credential_file.rb', line 15

def default_path
  File.join(%w(~ .aws credentials))
end

#profiles_hashHash<String,Hash>

Returns:

  • (Hash<String,Hash>)


20
21
22
# File 'lib/aws/session/credentials/credential_file.rb', line 20

def profiles_hash
  read.to_h
end

#profiles_hash=(hsh) ⇒ Object

Parameters:

  • prfs (Hash<String,Hash>)


25
26
27
# File 'lib/aws/session/credentials/credential_file.rb', line 25

def profiles_hash=(hsh)
  hsh.each { |key, value| self[key] = value }
end