jffjs/mongoid_auto_inc — pull request #5 by meltedice (2012-02-23 10:04:08+00:00)
Title: More than two auto_increment fields doesn't work

Hi,

I found a bug that more than 2 auto_increment field doesn't work due to @@incrementor variable.
So bugfixed.
Just changed @@incrementor class variable to incrementor variable like closure.

Thanks.

class DocumentA
include Mongoid::Document
auto_increment :seq, :seed => 10
end
class DocumentB
include Mongoid::Document
auto_increment :seq # this overwrote DocumentA's @@incrementor
end

DocumentA.create!.seq # => 1 # should be 11 but 1
DocumentA.create!.seq # => 2
DocumentB.create!.seq # => 3
DocumentB.create!.seq # => 4
DocumentB.create!.seq # => 5