Class: Fog::Storage::Rackspace::Directory
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::Rackspace::Directory
show all
- Defined in:
- lib/fog/rackspace/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
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_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 ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/fog/rackspace/models/storage/directory.rb', line 16
def destroy
requires :key
connection.delete_container(key)
connection.cdn.post_container(key, 'X-CDN-Enabled' => 'False')
true
rescue Excon::Errors::NotFound
false
end
|
#files ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/fog/rackspace/models/storage/directory.rb', line 25
def files
@files ||= begin
Fog::Storage::Rackspace::Files.new(
:directory => self,
:connection => connection
)
end
end
|
#public=(new_public) ⇒ Object
34
35
36
|
# File 'lib/fog/rackspace/models/storage/directory.rb', line 34
def public=(new_public)
@public = new_public
end
|
#public_url ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/fog/rackspace/models/storage/directory.rb', line 38
def public_url
requires :key
@public_url ||= begin
begin response = connection.cdn.head_container(key)
if response.['X-CDN-Enabled'] == 'True'
if connection.rackspace_cdn_ssl == true
response.['X-CDN-SSL-URI']
else
cdn_cname || response.['X-CDN-URI']
end
end
rescue Fog::Service::NotFound
nil
end
end
end
|
#save ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/fog/rackspace/models/storage/directory.rb', line 55
def save
requires :key
connection.put_container(key)
if @connection.cdn && @public
= 'X-CDN-URI'
if connection.rackspace_cdn_ssl == true
= 'X-CDN-SSL-URI'
end
@public_url = connection.cdn.put_container(key, 'X-CDN-Enabled' => 'True').[]
elsif @connection.cdn && !@public
connection.cdn.put_container(key, 'X-CDN-Enabled' => 'False')
@public_url = nil
elsif !@connection.cdn && @public
raise(Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided"))
end
true
end
|