Class: Aeolus::Image::Warehouse::BucketObject
- Inherits:
-
Object
- Object
- Aeolus::Image::Warehouse::BucketObject
- Defined in:
- lib/aeolus_image/model/warehouse/warehouse_client.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #attr(name) ⇒ Object
- #attr_list ⇒ Object
- #attrs(list) ⇒ Object
- #body ⇒ Object
- #delete! ⇒ Object
-
#initialize(connection, key, bucket) ⇒ BucketObject
constructor
A new instance of BucketObject.
- #set_attr(name, content) ⇒ Object
- #set_attrs(hash) ⇒ Object
- #set_body(body) ⇒ Object
Constructor Details
#initialize(connection, key, bucket) ⇒ BucketObject
Returns a new instance of BucketObject.
28 29 30 31 32 33 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 28 def initialize(connection, key, bucket) @connection = connection @key = key @bucket = bucket @path = "/#{@bucket.name}/#{@key}" end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
26 27 28 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 26 def key @key end |
Class Method Details
.create(connection, key, bucket, body, attrs = {}) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 35 def self.create(connection, key, bucket, body, attrs = {}) obj = new(connection, key, bucket) obj.set_body(body) obj.set_attrs(attrs) obj end |
Instance Method Details
#attr(name) ⇒ Object
64 65 66 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 64 def attr(name) attrs([name])[name] end |
#attr_list ⇒ Object
50 51 52 53 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 50 def attr_list result = @connection.do_request @path, :content => 'op=parts', :method => :post return result.xpath('/object/object_attr/@name').to_a.map {|item| item.value} end |
#attrs(list) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 55 def attrs(list) attrs = {} list.each do |att| next if att.match('-') attrs[att] = (@connection.do_request("#{@path}/#{att}", :plain => true) rescue nil) end attrs end |
#body ⇒ Object
42 43 44 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 42 def body @connection.do_request @path, :plain => true end |
#delete! ⇒ Object
79 80 81 82 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 79 def delete! @connection.do_request @path, :method => :delete true end |
#set_attr(name, content) ⇒ Object
74 75 76 77 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 74 def set_attr(name, content) path = "#{@path}/#{name}" @connection.do_request path, :content => content, :method => :put end |
#set_attrs(hash) ⇒ Object
68 69 70 71 72 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 68 def set_attrs(hash) hash.each do |name, content| set_attr(name, content) end end |
#set_body(body) ⇒ Object
46 47 48 |
# File 'lib/aeolus_image/model/warehouse/warehouse_client.rb', line 46 def set_body(body) @connection.do_request @path, :content => body, :method => :put end |