Class: WAZ::Blobs::Container
- Inherits:
-
Object
- Object
- WAZ::Blobs::Container
- Defined in:
- lib/waz/blobs/container.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#public_access ⇒ Object
Returns the value of attribute public_access.
Class Method Summary collapse
Instance Method Summary collapse
- #[](blob_name) ⇒ Object
- #blobs ⇒ Object
- #destroy! ⇒ Object
-
#initialize(name, metadata = nil) ⇒ Container
constructor
A new instance of Container.
- #metadata ⇒ Object
- #public_access? ⇒ Boolean
- #put_properties(properties = {}) ⇒ Object
- #store(blob_name, payload, content_type, options = {}) ⇒ Object
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
#name ⇒ Object
Returns the value of attribute name.
27 28 29 |
# File 'lib/waz/blobs/container.rb', line 27 def name @name end |
#properties ⇒ Object
Returns the value of attribute properties.
27 28 29 |
# File 'lib/waz/blobs/container.rb', line 27 def properties @properties end |
#public_access ⇒ Object
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
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 |
#blobs ⇒ Object
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 |
#metadata ⇒ Object
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
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, = {}) service_instance.put_blob("#{self.name}/#{blob_name}", payload, content_type, ) return BlobObject.new(blob_name, service_instance.generate_request_uri(nil, "#{self.name}/#{blob_name}"), content_type) end |