Module: Transit::Model::AutoIncrement

Extended by:
ActiveSupport::Concern
Defined in:
lib/transit/model/auto_increment.rb

Overview

Provides SQL like auto-incrementing of an id using a “uid” field

Instance Method Summary collapse

Instance Method Details

#generate_uidObject



14
15
16
17
18
# File 'lib/transit/model/auto_increment.rb', line 14

def generate_uid
  return true unless self.uid.nil?        
  ref = (self.class.superclass == Object ? self.class : self.class.superclass)
  self.uid = ref.max(:uid).to_i + 1
end