1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/rackspace/models/storage/directories.rb
2010-09-09 17:50:38 -07:00

34 lines
792 B
Ruby

require 'fog/collection'
require 'fog/rackspace/models/storage/directory'
module Fog
module Rackspace
class Storage
class Directories < Fog::Collection
model Fog::Rackspace::Storage::Directory
def all
data = connection.get_containers.body
load(data)
end
def get(key, options = {})
data = connection.get_container(key, options).body
directory = new(:key => key)
directory.files.merge_attributes(options)
directory.files.instance_variable_set(:@loaded, true)
data.each do |file|
directory.files << directory.files.new(file)
end
directory
rescue Fog::Rackspace::Storage::NotFound
nil
end
end
end
end
end