Class: Fog::Storage::GoogleJSON::Files
- Inherits:
-
Collection
- Object
- Collection
- Fog::Storage::GoogleJSON::Files
- Extended by:
- Deprecation
- Defined in:
- lib/fog/storage/google_json/models/files.rb
Instance Method Summary collapse
- #all(options = {}) ⇒ Object
- #each ⇒ Object
- #each_file_this_page ⇒ Object
- #get(key, options = {}, &block) ⇒ Object
- #get_https_url(key, expires, options = {}) ⇒ Object
- #metadata(key, options = {}) ⇒ Object (also: #head)
- #new(opts = {}) ⇒ Object
Instance Method Details
#all(options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/fog/storage/google_json/models/files.rb', line 18 def all( = {}) requires :directory parent = service.list_objects(directory.key, attributes.merge()) attributes[:next_page_token] = parent.next_page_token data = parent.to_h[:items] || [] load(data) end |
#each ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/storage/google_json/models/files.rb', line 27 def each if block_given? subset = dup.all subset.each_file_this_page { |f| yield f } while subset.next_page_token subset = subset.all(:page_token => subset.next_page_token) subset.each_file_this_page { |f| yield f } end end self end |
#each_file_this_page ⇒ Object
26 |
# File 'lib/fog/storage/google_json/models/files.rb', line 26 alias_method :each_file_this_page, :each |
#get(key, options = {}, &block) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/fog/storage/google_json/models/files.rb', line 40 def get(key, = {}, &block) requires :directory data = service.get_object(directory.key, key, **, &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
49 50 51 52 |
# File 'lib/fog/storage/google_json/models/files.rb', line 49 def get_https_url(key, expires, = {}) requires :directory service.get_object_https_url(directory.key, key, expires, **) end |
#metadata(key, options = {}) ⇒ Object Also known as: head
54 55 56 57 58 59 60 |
# File 'lib/fog/storage/google_json/models/files.rb', line 54 def (key, = {}) requires :directory data = service.(directory.key, key, **).to_h new(data) rescue ::Google::Apis::ClientError nil end |
#new(opts = {}) ⇒ Object
63 64 65 66 |
# File 'lib/fog/storage/google_json/models/files.rb', line 63 def new(opts = {}) requires :directory super({ :directory => directory }.merge(opts)) end |