Class: Fog::Brightbox::Storage::Directories

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/brightbox/models/storage/directories.rb

Constant Summary collapse

HEADER_ATTRIBUTES =
%w[X-Container-Bytes-Used X-Container-Object-Count X-Container-Read X-Container-Write].freeze

Instance Method Summary collapse

Instance Method Details

#allObject



11
12
13
14
# File 'lib/fog/brightbox/models/storage/directories.rb', line 11

def all
  data = service.get_containers.body
  load(data)
end

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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/brightbox/models/storage/directories.rb', line 16

def get(key, options = {})
  data = service.get_container(key, options)
  directory = new(key: key)
  data.headers.each do |header, value|
    if HEADER_ATTRIBUTES.include?(header)
      directory.merge_attributes(header => value)
    end
  end
  directory.files.merge_attributes(options)
  directory.files.instance_variable_set(:@loaded, true)

  data.body.each do |file|
    directory.files << directory.files.new(file)
  end
  directory
rescue Fog::Brightbox::Storage::NotFound
  nil
end