2010-03-19 18:29:42 -07:00
|
|
|
require 'fog/collection'
|
|
|
|
require 'fog/rackspace/models/files/directory'
|
|
|
|
|
2010-02-27 13:39:33 -08:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2010-09-08 13:50:23 -07:00
|
|
|
class Storage
|
2010-02-27 13:39:33 -08:00
|
|
|
|
|
|
|
class Directories < Fog::Collection
|
|
|
|
|
2010-09-08 13:50:23 -07:00
|
|
|
model Fog::Rackspace::Storage::Directory
|
2010-02-27 13:39:33 -08:00
|
|
|
|
|
|
|
def all
|
|
|
|
data = connection.get_containers.body
|
2010-03-06 20:02:10 -08:00
|
|
|
load(data)
|
2010-02-27 13:39:33 -08:00
|
|
|
end
|
|
|
|
|
2010-05-02 19:59:15 -07:00
|
|
|
def get(key, options = {})
|
|
|
|
data = connection.get_container(key, options).body
|
|
|
|
directory = new(:key => key)
|
2010-02-27 13:39:33 -08:00
|
|
|
directory.files.merge_attributes(options)
|
|
|
|
directory.files.instance_variable_set(:@loaded, true)
|
|
|
|
data.each do |file|
|
|
|
|
directory.files << directory.files.new(file)
|
|
|
|
end
|
|
|
|
directory
|
2010-09-08 13:50:23 -07:00
|
|
|
rescue Fog::Rackspace::Storage::NotFound
|
2010-02-27 13:39:33 -08:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|