Class: Lesli::ApplicationLesliRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Lesli::ApplicationLesliRecord
show all
- Defined in:
- app/models/lesli/application_lesli_record.rb
Constant Summary
collapse
- CHARSET =
"ABCDEFGHJKLMNPQRSTUVWXYZ"
Instance Method Summary
collapse
Instance Method Details
#generate_resource_uid(prefix: nil, length: 4) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/models/lesli/application_lesli_record.rb', line 40
def generate_resource_uid(prefix:nil, length:4)
year = Time.current.year % 100
month = Time.current.month
period = "#{year}#{month}"
letters = Array.new(length) { CHARSET.chars.sample }.join
return "#{letters}" unless period
return "#{period}-#{letters}" unless prefix
return "#{prefix}-#{period}-#{letters}"
end
|