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:
parent
ee35ea048c
commit
1d891fbb2b
2 changed files with 18 additions and 5 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue