Class: Fog::Storage::Ninefold::Directory

Inherits:
Model
  • Object
show all
Defined in:
lib/rackspace-fog/ninefold/models/storage/directory.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroy(opts = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/rackspace-fog/ninefold/models/storage/directory.rb', line 37

def destroy(opts={})
  if opts[:recursive]
    files.each {|f| f.destroy }
    directories.each do |d|
      d.files.each {|f| f.destroy }
      d.destroy(opts)
    end
  end
  connection.delete_namespace key
end

#directoriesObject



21
22
23
24
25
26
27
28
# File 'lib/rackspace-fog/ninefold/models/storage/directory.rb', line 21

def directories
  @directories ||= begin
               Fog::Storage::Ninefold::Directories.new(
                                                       :directory    => self,
                                                       :connection   => connection
                                                       )
  end
end

#filesObject



12
13
14
15
16
17
18
19
# File 'lib/rackspace-fog/ninefold/models/storage/directory.rb', line 12

def files
  @files ||= begin
               Fog::Storage::Ninefold::Files.new(
                                                  :directory    => self,
                                                  :connection   => connection
                                                  )
  end
end

#saveObject



30
31
32
33
34
35
# File 'lib/rackspace-fog/ninefold/models/storage/directory.rb', line 30

def save
  self.key = attributes[:directory].key + key if attributes[:directory]
  self.key = key + '/' unless key =~ /\/$/
  res = connection.post_namespace key
  reload
end