Class: Fog::Rackspace::Storage::Directory

Inherits:
Model
  • Object
show all
Extended by:
Deprecation
Defined in:
lib/fog/storage/models/rackspace/directory.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods included from Deprecation

deprecate, self_deprecate

Methods inherited from Model

#initialize, #inspect, #reload, #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, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



18
19
20
21
22
23
24
# File 'lib/fog/storage/models/rackspace/directory.rb', line 18

def destroy
  requires :key
  connection.delete_container(key)
  true
rescue Excon::Errors::NotFound
  false
end

#filesObject



26
27
28
29
30
31
32
33
# File 'lib/fog/storage/models/rackspace/directory.rb', line 26

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

#public=(new_public) ⇒ Object



35
36
37
# File 'lib/fog/storage/models/rackspace/directory.rb', line 35

def public=(new_public)
  @public = new_public
end

#public_urlObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/storage/models/rackspace/directory.rb', line 39

def public_url
  requires :key
  @public_url ||= begin
    begin response = connection.cdn.head_container(key)
      response.headers['X-CDN-Enabled'] == 'True' && response.headers['X-CDN-URI']
    rescue Fog::Service::NotFound
      nil
    end
  end
end

#saveObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fog/storage/models/rackspace/directory.rb', line 50

def save
  requires :key
  connection.put_container(key)
  if @public
    @public_url = connection.cdn.put_container(key, 'X-CDN-Enabled' => 'True').headers['X-CDN-URI']
  else
    connection.cdn.put_container(key, 'X-CDN-Enabled' => 'False')
    @public_url = nil
  end
  true
end