Skip to content

Commit

Permalink
Made has_details convert blank BigDecimal values to nil instead of 0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tarmo authored and erkki committed Feb 9, 2010
1 parent b7cdc51 commit 23d17fe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/has_details.rb
Expand Up @@ -52,7 +52,7 @@ def has_details(options = {})
elsif t == Integer elsif t == Integer
"val = (val.nil? ? nil : (Integer(val) rescue nil))" "val = (val.nil? ? nil : (Integer(val) rescue nil))"
elsif t == BigDecimal elsif t == BigDecimal
"val = val.is_a?(BigDecimal) ? val : val.to_d" "val = val.is_a?(BigDecimal) ? val : (val.blank? ? nil : val.to_d)"
else else
"raise \"Assigned value must be a #{t.inspect}\" unless val.nil? || val.is_a?(#{t.inspect})" "raise \"Assigned value must be a #{t.inspect}\" unless val.nil? || val.is_a?(#{t.inspect})"
end end
Expand Down

0 comments on commit 23d17fe

Please sign in to comment.