module Aws::Session::Credentials::FileProvider::YamlFileProvider
Mixin to store configuration in a YAML file
Public Instance Methods
[](key)
click to toggle source
# File lib/aws/session/credentials/file_provider/yaml_file_provider.rb, line 7 def [](key) read[key] end
[]=(key, value)
click to toggle source
# File lib/aws/session/credentials/file_provider/yaml_file_provider.rb, line 11 def []=(key, value) hash = read.dup hash[key] = value write(hash) end
read()
click to toggle source
@api private @return [Hash]
# File lib/aws/session/credentials/file_provider/yaml_file_provider.rb, line 19 def read return {} unless File.exist?(path) YAML.load(File.read(path)).deep_symbolize_keys end
write(hash)
click to toggle source
@api private @param [Hash] hash
# File lib/aws/session/credentials/file_provider/yaml_file_provider.rb, line 26 def write(hash) hsh = hash.deep_stringify_keys FileUtils.mkdir_p(File.dirname(path)) unless File.exist?(path) File.open(path, 'w', 0600) { |file| file.write(YAML.dump(hsh)) } end