Skip to content

Commit

Permalink
added default value support
Browse files Browse the repository at this point in the history
  • Loading branch information
afrojas committed May 9, 2012
1 parent 4c9c3c3 commit 9b7c00f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/dynamoid/persistence.rb
Expand Up @@ -75,7 +75,11 @@ def undump(incoming = nil)
#
# @since 0.2.0
def undump_field(value, options)
return if value.nil? || (value.respond_to?(:empty?) && value.empty?)
if options[:default] && value.nil?
value = options[:default]
else
return if value.nil? || (value.respond_to?(:empty?) && value.empty?)
end

case options[:type]
when :string
Expand Down

0 comments on commit 9b7c00f

Please sign in to comment.