Permalink
Browse files

Tweak $inc code

  • Loading branch information...
1 parent bbaaf53 commit 41832fbfea8b6f7c2c8ebb89048d92e146ce8f81 @gdb committed Oct 31, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/embedded-mongo/backend/collection.rb
@@ -224,7 +224,10 @@ def apply_update_directive!(directive_key, directive_value, doc)
directive_value.each { |k, v| doc[k] = v }
when '$inc'
directive_value.each do |k, v|
- raise Mongo::OperationFailure.new("Cannot apply $inc modifier to non-number: #{k}=#{doc[k].inspect}") unless doc[k].kind_of?(Numeric)
+ unless doc[k].kind_of?(Numeric)
+ raise Mongo::OperationFailure.new("Cannot apply $inc modifier to non-number", 10140)
+ end
+
doc[k] += v
end
else

0 comments on commit 41832fb

Please sign in to comment.