Class: Fog::Rackspace::Storage::Directory
- Inherits:
-
Model
- Object
- Model
- Fog::Rackspace::Storage::Directory
show all
- Defined in:
- lib/fog/storage/models/rackspace/directory.rb
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect, #reload, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#destroy ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/fog/storage/models/rackspace/directory.rb', line 15
def destroy
requires :key
connection.delete_container(key)
connection.cdn.put_container(key, 'X-CDN-Enabled' => 'False')
true
rescue Excon::Errors::NotFound
false
end
|
#files ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/fog/storage/models/rackspace/directory.rb', line 24
def files
@files ||= begin
Fog::Rackspace::Storage::Files.new(
:directory => self,
:connection => connection
)
end
end
|
#public=(new_public) ⇒ Object
33
34
35
|
# File 'lib/fog/storage/models/rackspace/directory.rb', line 33
def public=(new_public)
@public = new_public
end
|
#public_url ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/fog/storage/models/rackspace/directory.rb', line 37
def public_url
requires :key
@public_url ||= begin
begin response = connection.cdn.head_container(key)
response.['X-CDN-Enabled'] == 'True' && response.['X-CDN-URI']
rescue Fog::Service::NotFound
nil
end
end
end
|
#save ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/fog/storage/models/rackspace/directory.rb', line 48
def save
requires :key
connection.put_container(key)
if @public
@public_url = connection.cdn.put_container(key, 'X-CDN-Enabled' => 'True').['X-CDN-URI']
else
connection.cdn.put_container(key, 'X-CDN-Enabled' => 'False')
@public_url = nil
end
true
end
|