2010-03-19 21:29:42 -04:00
|
|
|
require 'fog/collection'
|
2010-09-09 20:50:38 -04:00
|
|
|
require 'fog/rackspace/models/storage/directory'
|
2010-03-19 21:29:42 -04:00
|
|
|
|
2010-02-27 16:39:33 -05:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2010-09-08 16:50:23 -04:00
|
|
|
class Storage
|
2010-02-27 16:39:33 -05:00
|
|
|
|
|
|
|
class Directories < Fog::Collection
|
|
|
|
|
2010-09-08 16:50:23 -04:00
|
|
|
model Fog::Rackspace::Storage::Directory
|
2010-02-27 16:39:33 -05:00
|
|
|
|
|
|
|
def all
|
|
|
|
data = connection.get_containers.body
|
2010-03-06 23:02:10 -05:00
|
|
|
load(data)
|
2010-02-27 16:39:33 -05:00
|
|
|
end
|
|
|
|
|
2010-05-02 22:59:15 -04:00
|
|
|
def get(key, options = {})
|
|
|
|
data = connection.get_container(key, options).body
|
|
|
|
directory = new(:key => key)
|
2010-02-27 16:39:33 -05: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 16:50:23 -04:00
|
|
|
rescue Fog::Rackspace::Storage::NotFound
|
2010-02-27 16:39:33 -05:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|