Skip to content

Commit

Permalink
Tweak $inc code
Browse files Browse the repository at this point in the history
  • Loading branch information
gdb committed Oct 31, 2012
1 parent bbaaf53 commit 41832fb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/embedded-mongo/backend/collection.rb
Expand Up @@ -224,7 +224,10 @@ def apply_update_directive!(directive_key, directive_value, doc)
directive_value.each { |k, v| doc[k] = v } directive_value.each { |k, v| doc[k] = v }
when '$inc' when '$inc'
directive_value.each do |k, v| 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 doc[k] += v
end end
else else
Expand Down

0 comments on commit 41832fb

Please sign in to comment.