2010-03-19 21:29:42 -04:00
|
|
|
require 'fog/model'
|
|
|
|
|
2010-02-27 16:39:33 -05:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2010-03-19 21:29:42 -04:00
|
|
|
module Files
|
2010-02-27 16:39:33 -05:00
|
|
|
|
|
|
|
class Directory < Fog::Model
|
|
|
|
|
|
|
|
identity :name
|
|
|
|
|
|
|
|
attribute :bytes
|
|
|
|
attribute :count
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :name
|
|
|
|
connection.delete_container(@name)
|
|
|
|
true
|
|
|
|
rescue Excon::Errors::NotFound
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def files
|
|
|
|
@files ||= begin
|
|
|
|
Fog::Rackspace::Files::Files.new(
|
|
|
|
:directory => self,
|
|
|
|
:connection => connection
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :name
|
|
|
|
connection.put_container(@name)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|