lib/fog/openstack/models/compute/metadata.rb in fog-maestrodev-1.8.0.20130114204828 vs lib/fog/openstack/models/compute/metadata.rb in fog-maestrodev-1.14.0.20130806165225

- old
+ new

@@ -16,40 +16,39 @@ def all requires :parent metadata = service.list_metadata(collection_name, @parent.id).body['metadata'] metas = [] - metadata.each_pair {|k,v| metas << {"key" => k, "value" => v} } + metadata.each_pair {|k,v| metas << {"key" => k, "value" => v} } unless metadata.nil? load(metas) end def get(key) requires :parent - data = service.get_meta(collection_name, @parent.id, key).body["meta"] + data = service.get_metadata(collection_name, @parent.id, key).body["meta"] metas = [] data.each_pair {|k,v| metas << {"key" => k, "value" => v} } new(metas[0]) rescue Fog::Compute::OpenStack::NotFound nil end def update(data=nil) requires :parent - service.update_metadata(collection_name, @parent.id, meta_hash(data)) + service.update_metadata(collection_name, @parent.id, to_hash(data)) end def set(data=nil) requires :parent - service.set_metadata(collection_name, @parent.id, meta_hash(data)) + service.set_metadata(collection_name, @parent.id, to_hash(data)) end def new(attributes = {}) requires :parent super({ :parent => @parent }.merge!(attributes)) end - private - def meta_hash(data=nil) + def to_hash(data=nil) if data.nil? data={} self.each do |meta| if meta.is_a?(Fog::Compute::OpenStack::Metadatum) then data.store(meta.key, meta.value)