Make "property :foo, :default => false" work

Before a default value of false was treated like a default of nil,
  which is not the same.

Signed-off-by: Matt Aimonetti <mattaimonetti@gmail.com>
This commit is contained in:
Mutwin Kraus 2009-04-26 10:31:19 +08:00 committed by Matt Aimonetti
parent 75a5018b12
commit f7bbee8243
3 changed files with 9 additions and 3 deletions

View file

@ -24,7 +24,7 @@ module CouchRest
self.class.properties.each do |property|
key = property.name.to_s
# let's make sure we have a default and we can assign the value
if property.default && (self.respond_to?("#{key}=") || self.key?(key))
if !property.default.nil? && (self.respond_to?("#{key}=") || self.key?(key))
if property.default.class == Proc
self[key] = property.default.call
else