Class: SwiftStorage::Container

Inherits:
Node
  • Object
show all
Defined in:
lib/swift_storage/container.rb

Instance Attribute Summary

Attributes inherited from Node

#name, #parent

Instance Method Summary collapse

Methods inherited from Node

#clear_cache, #delete, #delete_if_exists, #exists?, #get_lines, #headers, #initialize, #metadata, #request, #service, #to_s

Methods included from Utils

#hmac, #sig_to_hex, #struct

Constructor Details

This class inherits a constructor from SwiftStorage::Node

Instance Method Details

#aclStruct

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

#createObject

Create the container



25
26
27
# File 'lib/swift_storage/container.rb', line 25

def create
  request(relative_path, :method => :put)
end

#objectsSwiftStorage::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_pathObject



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:jon give 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