Class: SequenceGenerator::Sequence

Inherits:
ApplicationRecord show all
Includes:
ActsAsSequenced
Defined in:
app/models/sequence_generator/sequence.rb

Constant Summary

Constants included from ActsAsSequenced

ActsAsSequenced::ColumnWithSamePurposeExists, ActsAsSequenced::DEFAULT_OPTIONS

Instance Method Summary collapse

Methods included from ActsAsSequenced

included

Instance Method Details

#generate_sequence_numberObject



12
13
14
15
16
17
# File 'app/models/sequence_generator/sequence.rb', line 12

def generate_sequence_number
  sequence_number = "%06d" % (sequential_id + 1).to_s
  generated_sequential_id = "#{sequence_prefix}#{sequence_number}"
  self.update(sequential_id: sequential_id + 1)
  return generated_sequential_id
end

#validate_sequential_idObject



8
9
10
# File 'app/models/sequence_generator/sequence.rb', line 8

def validate_sequential_id
  validates_presence_of :sequential_id, :purpose
end