Sha256: ce014e20d462be1a39856c9f4a4ddd43948f9b7fd1685c984cba7f809b7dabe2
Contents?: true
Size: 470 Bytes
Versions: 1
Compression:
Stored size: 470 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 = number + 1 document_number.save! number end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
document_number-0.9.2 | lib/document_number/numerator.rb |