1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[rackspace|storage] added delete method to metadata

This commit is contained in:
Kyle Rames 2013-02-13 10:15:48 -06:00
parent ee35ea048c
commit 1d891fbb2b
2 changed files with 18 additions and 5 deletions

View file

@ -18,11 +18,18 @@ module Fog
def initialize(hash={}) def initialize(hash={})
@data = hash || {} @data = hash || {}
@deleted_hash = {}
end
def delete(key)
data.delete(key)
@deleted_hash[key] = nil
end end
def to_headers def to_headers
headers = {} headers = {}
@data.each_pair do |k,v| h = data.merge(@deleted_hash)
h.each_pair do |k,v|
key = to_header_key(k,v) key = to_header_key(k,v)
headers[key] = v || DUMMY_VALUE headers[key] = v || DUMMY_VALUE
end end
@ -41,11 +48,11 @@ module Fog
end end
def respond_to?(method_sym, include_private = false) def respond_to?(method_sym, include_private = false)
super(method_sym, include_private) || @data.method_missing(method_missing, include_private) super(method_sym, include_private) || data.method_missing(method_missing, include_private)
end end
def method_missing(method, *args, &block) def method_missing(method, *args, &block)
@data.send(method, *args, &block) data.send(method, *args, &block)
end end
private private

View file

@ -32,11 +32,17 @@ Shindo.tests('Fog::Rackspace::Storage | directory', ['rackspace']) do
@instance.save @instance.save
container_meta_attributes container_meta_attributes
end end
tests('delete metadata').returns({"X-Container-Meta-Draft"=>"true"}) do tests('set metadata to nil').returns({"X-Container-Meta-Draft"=>"true"}) do
@instance.metadata[:color] = nil @instance.metadata[:color] = nil
@instance.save @instance.save
container_meta_attributes container_meta_attributes
end
tests('delete metadata').returns({}) do
@instance.metadata.delete(:draft)
@instance.save
container_meta_attributes
end end
end end
end end