Class: Fog::Storage::GoogleJSON::Files

Inherits:
Collection
  • Object
show all
Extended by:
Deprecation
Defined in:
lib/fog/storage/google_json/models/files.rb

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/fog/storage/google_json/models/files.rb', line 17

def all(options = {})
  requires :directory
  data = service.list_objects(directory.key, attributes.merge(options))
                .to_h[:items] || []
  load(data)
end

#eachObject



25
26
27
28
29
30
31
32
# File 'lib/fog/storage/google_json/models/files.rb', line 25

def each
  if block_given?
    subset = dup.all

    subset.each_file_this_page { |f| yield f }
  end
  self
end

#each_file_this_pageObject



24
# File 'lib/fog/storage/google_json/models/files.rb', line 24

alias_method :each_file_this_page, :each

#get(key, options = {}, &block) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/fog/storage/google_json/models/files.rb', line 34

def get(key, options = {}, &block)
  requires :directory
  data = service.get_object(directory.key, key, **options, &block).to_h
  new(data)
rescue ::Google::Apis::ClientError => e
  raise e unless e.status_code == 404
  nil
end

#get_https_url(key, expires, options = {}) ⇒ Object



43
44
45
46
# File 'lib/fog/storage/google_json/models/files.rb', line 43

def get_https_url(key, expires, options = {})
  requires :directory
  service.get_object_https_url(directory.key, key, expires, options)
end

#metadata(key, options = {}) ⇒ Object Also known as: head



48
49
50
51
52
53
54
# File 'lib/fog/storage/google_json/models/files.rb', line 48

def (key, options = {})
  requires :directory
  data = service.(directory.key, key, options).to_h
  new(data)
rescue ::Google::Apis::ClientError
  nil
end

#new(opts = {}) ⇒ Object



57
58
59
60
# File 'lib/fog/storage/google_json/models/files.rb', line 57

def new(opts = {})
  requires :directory
  super({ :directory => directory }.merge(opts))
end