mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Minor fix and add a destroy method.
This commit is contained in:
parent
7f5dd98bcc
commit
09e6bcd34e
1 changed files with 18 additions and 8 deletions
|
@ -16,10 +16,19 @@ module Fog
|
|||
|
||||
def all
|
||||
requires :parent
|
||||
metadata = connection.list_metadata(collection_name, @parent.id).body['metadata']
|
||||
metas = []
|
||||
metadata.each_pair {|k,v| metas << {"key" => k, "value" => v} }
|
||||
load(metas)
|
||||
if @parent.id
|
||||
metadata = connection.list_metadata(collection_name, @parent.id).body['metadata']
|
||||
metas = []
|
||||
metadata.each_pair {|k,v| metas << {"key" => k, "value" => v} }
|
||||
load(metas)
|
||||
end
|
||||
end
|
||||
|
||||
def destroy(key)
|
||||
requires :parent
|
||||
connection.delete_meta(collection_name, @parent.id, key)
|
||||
rescue Fog::Compute::HP::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def get(key)
|
||||
|
@ -32,9 +41,9 @@ module Fog
|
|||
nil
|
||||
end
|
||||
|
||||
def update(data=nil)
|
||||
def new(attributes = {})
|
||||
requires :parent
|
||||
connection.update_metadata(collection_name, @parent.id, meta_hash(data))
|
||||
super({ :parent => @parent }.merge!(attributes))
|
||||
end
|
||||
|
||||
def set(data=nil)
|
||||
|
@ -42,11 +51,12 @@ module Fog
|
|||
connection.set_metadata(collection_name, @parent.id, meta_hash(data))
|
||||
end
|
||||
|
||||
def new(attributes = {})
|
||||
def update(data=nil)
|
||||
requires :parent
|
||||
super({ :parent => @parent }.merge!(attributes))
|
||||
connection.update_metadata(collection_name, @parent.id, meta_hash(data))
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def meta_hash(data=nil)
|
||||
if data.nil?
|
||||
|
|
Loading…
Add table
Reference in a new issue