<commit_before>require "mongoid_auto_increment/incrementor"

module MongoidAutoIncrement
  extend ActiveSupport::Concern

  module ClassMethods
    def auto_increment(name, options={})
      field name, :type => Integer
      #seq_name = "#{self.name.downcase}_#{name}"
      seq_name = "#{self.name.downcase}"
      @@incrementor = MongoidAutoIncrement::Incrementor.new unless defined? @@incrementor

      before_create do
        #if #{name} is not Integer instance,then to replace it with Integer.  
        self.send("#{name}=", @@incrementor.inc(seq_name, options)) unless self.send("#{name}").is_a?(Integer)
      end
    end
  end
end

module Mongoid
  module Document
    include MongoidAutoIncrement
  end
end<commit_msg>Update lib/mongoid_auto_increment.rb<commit_after>require "mongoid_auto_increment/incrementor"

module MongoidAutoIncrement
  extend ActiveSupport::Concern

  module ClassMethods
    def auto_increment(name, options={})
      field name, :type => Integer
      #seq_name = "#{self.name.downcase}_#{name}"
      seq_name = "#{self.name.downcase}"
      @@incrementor = MongoidAutoIncrement::Incrementor.new unless defined? @@incrementor

      before_create { self.send("#{name}=", @@incrementor.inc(seq_name, options)) }
      end
    end
  end
end

module Mongoid
  module Document
    include MongoidAutoIncrement
  end
end
{'fraction_non_alphanumeric': 0.10914454277286136, 'fraction_numerical': 0.0, 'mean_word_length': 4.082397003745318, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7123630', 'n_tokens_mistral': 430, 'n_tokens_neox': 422, 'n_words': 94}