Class: Attached::Storage::Google

Inherits:
Fog
  • Object
show all
Defined in:
lib/attached/storage/google.rb

Instance Attribute Summary collapse

Attributes inherited from Fog

#defaults

Instance Method Summary collapse

Methods inherited from Fog

#destroy, #retrieve, #save

Methods inherited from Base

#destroy, #options, #parse, #retrieve, #save

Constructor Details

#initialize(credentials) ⇒ Google

Create a new interface supporting save and destroy operations.

Usage:

Attached::Storage::Google.new()
Attached::Storage::Google.new("google.yml")


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/attached/storage/google.rb', line 21

def initialize(credentials)
  super

  credentials = parse(credentials)


  @bucket            = credentials[:bucket]            || credentials['bucket']
  @access_key_id     = credentials[:access_key_id]     || credentials['access_key_id']
  @secret_access_key = credentials[:secret_access_key] || credentials['secret_access_key']

  raise "'bucket' must be specified if using 'google' for storage" unless @bucket
end

Instance Attribute Details

#access_key_idObject (readonly)

Returns the value of attribute access_key_id.



10
11
12
# File 'lib/attached/storage/google.rb', line 10

def access_key_id
  @access_key_id
end

#bucketObject (readonly)

Returns the value of attribute bucket.



9
10
11
# File 'lib/attached/storage/google.rb', line 9

def bucket
  @bucket
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



11
12
13
# File 'lib/attached/storage/google.rb', line 11

def secret_access_key
  @secret_access_key
end

Instance Method Details

#hostObject

Access the host (e.g. attached.commondatastorage.googleapis.com/) for a storage service.

Usage:

storage.host


41
42
43
# File 'lib/attached/storage/google.rb', line 41

def host()
  "https://#{self.bucket}.commondatastorage.googleapis.com/"
end