Class: Fog::Storage::Ninefold::Directories
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::Storage::Ninefold::Directories
- Defined in:
- lib/rackspace-fog/ninefold/models/storage/directories.rb
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
Methods inherited from Collection
#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #reload, #table, #to_json
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::Collection
Instance Method Details
#all ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rackspace-fog/ninefold/models/storage/directories.rb', line 14 def all directory ? ns = directory.key : ns = '' ns = ns + '/' unless ns =~ /\/$/ data = connection.get_namespace(ns).body[:DirectoryList] data = {:DirectoryEntry => []} if data.kind_of? String data[:DirectoryEntry] = [data[:DirectoryEntry]] if data[:DirectoryEntry].kind_of? Hash dirs = data[:DirectoryEntry].select {|de| de[:FileType] == 'directory'} dirs.each do |d| d[:Filename] = ns + d[:Filename] if directory d[:Filename] += '/' unless d[:Filename] =~ /\/$/ end load(dirs) end |
#get(key, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rackspace-fog/ninefold/models/storage/directories.rb', line 28 def get(key, = {}) return nil if key == '' # Root dir shouldn't be retrieved like this. key =~ /\/$/ ? ns = key : ns = key + '/' res = connection.get_namespace ns = res.headers['x-emc-meta'] obj_id = .scan(/objectid=(\w+),/).flatten[0] new(:objectid => obj_id, :key => ns) rescue Fog::Storage::Ninefold::NotFound nil end |
#new(attributes = {}) ⇒ Object
39 40 41 42 |
# File 'lib/rackspace-fog/ninefold/models/storage/directories.rb', line 39 def new(attributes ={}) attributes = {:directory => directory}.merge(attributes) if directory super(attributes) end |