2010-03-19 21:29:42 -04:00
|
|
|
require 'fog/model'
|
2010-05-02 01:10:11 -04:00
|
|
|
require 'fog/rackspace/models/files/files'
|
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 Directory < Fog::Model
|
2010-05-02 22:59:15 -04:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate(:name, :key)
|
2010-05-04 17:31:42 -04:00
|
|
|
deprecate(:name=, :key=)
|
2010-02-27 16:39:33 -05:00
|
|
|
|
2010-05-04 17:31:42 -04:00
|
|
|
identity :key, ['name']
|
2010-02-27 16:39:33 -05:00
|
|
|
|
|
|
|
attribute :bytes
|
|
|
|
attribute :count
|
|
|
|
|
|
|
|
def destroy
|
2010-05-02 22:59:15 -04:00
|
|
|
requires :key
|
|
|
|
connection.delete_container(key)
|
2010-02-27 16:39:33 -05:00
|
|
|
true
|
|
|
|
rescue Excon::Errors::NotFound
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def files
|
|
|
|
@files ||= begin
|
|
|
|
Fog::Rackspace::Files::Files.new(
|
|
|
|
:directory => self,
|
|
|
|
:connection => connection
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2010-05-02 22:59:15 -04:00
|
|
|
requires :key
|
|
|
|
connection.put_container(key)
|
2010-02-27 16:39:33 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|