Class: SwiftStorage::Container
- Defined in:
- lib/swift_storage/container.rb
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#acl ⇒ Struct
Read the container meta data.
-
#create ⇒ Object
Create the container.
-
#objects ⇒ SwiftStorage::ObjectCollection
Returns the object collection for this container.
- #relative_path ⇒ Object
-
#write(write_acl: nil, read_acl: nil) ⇒ Object
Write the container meta data.
Methods inherited from Node
#clear_cache, #delete, #delete_if_exists, #exists?, #get_lines, #headers, #initialize, #metadata, #request, #service, #to_s
Methods included from Utils
Constructor Details
This class inherits a constructor from SwiftStorage::Node
Instance Method Details
#acl ⇒ Struct
Read the container meta data
59 60 61 62 63 |
# File 'lib/swift_storage/container.rb', line 59 def acl r = headers.read.split(',') rescue nil w = headers.write.split(',') rescue nil struct(:read => r, :write => w) end |
#create ⇒ Object
Create the container
25 26 27 |
# File 'lib/swift_storage/container.rb', line 25 def create request(relative_path, :method => :put) end |
#objects ⇒ SwiftStorage::ObjectCollection
Returns the object collection for this container
19 20 21 |
# File 'lib/swift_storage/container.rb', line 19 def objects @objects ||= SwiftStorage::ObjectCollection.new(self) end |
#relative_path ⇒ Object
6 7 8 |
# File 'lib/swift_storage/container.rb', line 6 def relative_path name end |
#write(write_acl: nil, read_acl: nil) ⇒ Object
Note:
This overrides all ACL set on the container.
Write the container meta data
Each ACL is a string in the following format:
team:jongive access to user "jon" of account "team"
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/swift_storage/container.rb', line 43 def write(write_acl: nil, read_acl: nil) h = {} read_acl = read_acl.join(',') if read_acl.respond_to?(:to_ary) write_acl = write_acl.join(',') if write_acl.respond_to?(:to_ary) h[H::CONTAINER_READ] = read_acl h[H::CONTAINER_WRITE] = write_acl request(relative_path, :method => :post, :headers => h) end |