Class: OpenstackBridge::Container

Inherits:
Struct
  • Object
show all
Defined in:
lib/openstack_bridge/container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#containerObject

Returns the value of attribute container

Returns:

  • (Object)

    the current value of container



2
3
4
# File 'lib/openstack_bridge/container.rb', line 2

def container
  @container
end

#swiftObject

Returns the value of attribute swift

Returns:

  • (Object)

    the current value of swift



2
3
4
# File 'lib/openstack_bridge/container.rb', line 2

def swift
  @swift
end

Instance Method Details

#create(name, content) ⇒ Object



17
18
19
# File 'lib/openstack_bridge/container.rb', line 17

def create(name, content)
  swift.request(:put, file_path(name), content)
end

#delete(name) ⇒ Object



21
22
23
# File 'lib/openstack_bridge/container.rb', line 21

def delete(name)
  swift.request(:delete, file_path(name))
end

#exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
# File 'lib/openstack_bridge/container.rb', line 3

def exists?(name)
  (200..299).include? swift.request(:head, file_path(name)).code
rescue OpenstackBridge::Error
  false
end

#objectsObject



9
10
11
# File 'lib/openstack_bridge/container.rb', line 9

def objects
  swift.request(:get, container_path).raw_body.split("\n")
end

#read(name) ⇒ Object



13
14
15
# File 'lib/openstack_bridge/container.rb', line 13

def read(name)
  swift.request(:get, file_path(name)).raw_body
end