Sha256: ad0b278d49af0ecde1002a167cb651407d37f54b46dabdefeef3f844e875abb0
Contents?: true
Size: 462 Bytes
Versions: 2
Compression:
Stored size: 462 Bytes
Contents
require "active_record/base" module DocumentNumber class Numerator def self.next_number(object, options) DocumentNumber.transaction do document_number = DocumentNumber.lock(true).find_or_initialize_by(document: object.class.to_s.underscore) number = document_number.number == 1 ? options[:start] : document_number.number document_number.number += 1 document_number.save! number end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
document_number-0.9.1 | lib/document_number/numerator.rb |
document_number-0.9.0 | lib/document_number/numerator.rb |