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



19
20
21
# File 'lib/openstack_bridge/container.rb', line 19

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

#delete(name) ⇒ Object



23
24
25
# File 'lib/openstack_bridge/container.rb', line 23

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

#exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#objectsObject



11
12
13
# File 'lib/openstack_bridge/container.rb', line 11

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

#read(name) ⇒ Object



15
16
17
# File 'lib/openstack_bridge/container.rb', line 15

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