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

Merge pull request #445 from brianhartsock/squash_false

Fixed #444 - Unable to squash kvp with false values
This commit is contained in:
Wesley Beary 2011-07-20 16:00:18 -07:00
commit b6921d255b
2 changed files with 14 additions and 3 deletions

View file

@ -71,8 +71,10 @@ module Fog
class_eval <<-EOS, __FILE__, __LINE__
def #{name}=(new_data)
if new_data.is_a?(Hash)
if new_data[:#{squash}] || new_data["#{squash}"]
attributes[:#{name}] = new_data[:#{squash}] || new_data["#{squash}"]
if new_data.has_key?(:#{squash})
attributes[:#{name}] = new_data[:#{squash}]
elsif new_data.has_key?("#{squash}")
attributes[:#{name}] = new_data["#{squash}"]
else
attributes[:#{name}] = [ new_data ]
end

View file

@ -19,6 +19,15 @@ Shindo.tests('Fog::Attributes', 'core') do
@model.key
end
tests('"keys" => {"id" => false}').returns(false) do
@model.merge_attributes("keys" => {'id' => false })
@model.key
end
tests('"keys" => {:id => false}').returns(false) do
@model.merge_attributes("keys" => {:id => false })
@model.key
end
end
tests(':type => :time') do
@ -42,4 +51,4 @@ Shindo.tests('Fog::Attributes', 'core') do
end
end
end