Class: Fog::Storage::GoogleJSON::Directory
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::GoogleJSON::Directory
- Defined in:
- lib/fog/storage/google_json/models/directory.rb
Instance Method Summary collapse
- #acl=(new_acl) ⇒ Object
- #destroy ⇒ Object
- #files ⇒ Object
- #public=(new_public) ⇒ Object
- #public_url ⇒ Object
- #save ⇒ Object
Instance Method Details
#acl=(new_acl) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/fog/storage/google_json/models/directory.rb', line 7 def acl=(new_acl) valid_acls = %w(private projectPrivate publicRead publicReadWrite authenticatedRead) unless valid_acls.include?(new_acl) raise ArgumentError.new("acl must be one of [#{valid_acls.join(', ')}]") end @acl = new_acl end |
#destroy ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/fog/storage/google_json/models/directory.rb', line 15 def destroy requires :key service.delete_bucket(key) true rescue Fog::Errors::NotFound false end |
#files ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/fog/storage/google_json/models/directory.rb', line 23 def files @files ||= begin Fog::Storage::GoogleJSON::Files.new( :directory => self, :service => service ) end end |
#public=(new_public) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fog/storage/google_json/models/directory.rb', line 32 def public=(new_public) if new_public @acl = "publicRead" else @acl = "private" end new_public end |
#public_url ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fog/storage/google_json/models/directory.rb', line 41 def public_url requires :key acl = service.get_bucket_acl(key).body if acl["items"].detect { |entry| entry["entity"] == "allUsers" && entry["role"] == "READER" } if key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/ "https://#{key}.storage.googleapis.com" else "https://storage.googleapis.com/#{key}" end end end |
#save ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/fog/storage/google_json/models/directory.rb', line 53 def save requires :key = {} ["predefinedAcl"] = @acl if @acl ["LocationConstraint"] = @location if @location ["StorageClass"] = attributes[:storage_class] if attributes[:storage_class] service.put_bucket(key, ) true end |