Class: WAZ::Blobs::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/waz/blobs/container.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, metadata = nil) ⇒ Container

Returns a new instance of Container.



29
30
31
32
# File 'lib/waz/blobs/container.rb', line 29

def initialize(name,  = nil)
  self.name = name
  self.properties = 
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



27
28
29
# File 'lib/waz/blobs/container.rb', line 27

def name
  @name
end

#propertiesObject

Returns the value of attribute properties.



27
28
29
# File 'lib/waz/blobs/container.rb', line 27

def properties
  @properties
end

#public_accessObject

Returns the value of attribute public_access.



27
28
29
# File 'lib/waz/blobs/container.rb', line 27

def public_access
  @public_access
end

Class Method Details

.create(name) ⇒ Object



6
7
8
9
# File 'lib/waz/blobs/container.rb', line 6

def create(name)
  service_instance.create_container(name)
  return Container.new(name)
end

.find(name) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/waz/blobs/container.rb', line 11

def find(name)
  begin 
    properties = service_instance.get_container_properties(name)
    return Container.new(name, properties)
  rescue RestClient::ResourceNotFound
    return nil
  end
end

Instance Method Details

#[](blob_name) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'lib/waz/blobs/container.rb', line 67

def [](blob_name)
  begin
    properties = service_instance.get_blob_properties("#{self.name}/#{blob_name}")
    return BlobObject.new(blob_name, 
                          service_instance.generate_request_uri(nil, "#{self.name}/#{blob_name}"),
                          properties[:content_type])
  rescue RestClient::ResourceNotFound
    return nil
  end
end

#blobsObject



56
57
58
# File 'lib/waz/blobs/container.rb', line 56

def blobs
  service_instance.list_blobs(name).map { |blob| WAZ::Blobs::BlobObject.new(blob[:name], blob[:url], blob[:content_type]) }
end

#destroy!Object



43
44
45
# File 'lib/waz/blobs/container.rb', line 43

def destroy!
  service_instance.delete_container(self.name)
end

#metadataObject



34
35
36
# File 'lib/waz/blobs/container.rb', line 34

def 
  self.properties ||= service_instance.get_container_properties(self.name)
end

#public_access?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/waz/blobs/container.rb', line 47

def public_access?
  public_access ||= service_instance.get_container_acl(self.name)
end

#put_properties(properties = {}) ⇒ Object



38
39
40
41
# File 'lib/waz/blobs/container.rb', line 38

def put_properties(properties = {})
  service_instance.set_container_properties(self.name, properties)
  self.properties = .merge!(properties)
end

#store(blob_name, payload, content_type, options = {}) ⇒ Object



60
61
62
63
64
65
# File 'lib/waz/blobs/container.rb', line 60

def store(blob_name, payload, content_type, options = {})
  service_instance.put_blob("#{self.name}/#{blob_name}", payload, content_type, options)
  return BlobObject.new(blob_name, 
                        service_instance.generate_request_uri(nil, "#{self.name}/#{blob_name}"),
                        content_type)
end