Method: HP::Cloud::AuthCache#write

Defined in:
lib/hpcloud/auth_cache.rb

#write(opts, creds) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/hpcloud/auth_cache.rb', line 97

def write(opts, creds)
   = get_name(opts)
  @aucas[] = creds;
  config = @aucas[]
  if config.nil?
    remove(opts)
    return
  end
  file_name = get_file_name(opts)
  begin
    FileUtils.mkpath(@directory)
    File.open(file_name, 'w') do |file|
      file.write config.to_yaml
    end
  rescue Exception => e
    raise Exception.new("Error writing file #{file_name}")
  end
end