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")


17
18
19
20
21
22
23
24
25
# File 'lib/attached/storage/google.rb', line 17

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.



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

def access_key_id
  @access_key_id
end

#bucketObject (readonly)

Returns the value of attribute bucket.



7
8
9
# File 'lib/attached/storage/google.rb', line 7

def bucket
  @bucket
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



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

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


32
33
34
# File 'lib/attached/storage/google.rb', line 32

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