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:
parent
75a5018b12
commit
f7bbee8243
3 changed files with 9 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -30,11 +30,11 @@ module CouchRest
|
|||
@validation_format = options.delete(:format) if options[:format]
|
||||
@read_only = options.delete(:read_only) if options[:read_only]
|
||||
@alias = options.delete(:alias) if options[:alias]
|
||||
@default = options.delete(:default) if options[:default]
|
||||
@default = options.delete(:default) unless options[:default].nil?
|
||||
@casted = options[:casted] ? true : false
|
||||
@init_method = options[:send] ? options.delete(:send) : 'new'
|
||||
@options = options
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue