Method: Jets::Resource.truncate_id
- Defined in:
- lib/jets/resource.rb
.truncate_id(id, postfix = '') ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jets/resource.rb', line 29 def self.truncate_id(id, postfix = '') # Api Gateway resource name has a limit of 64 characters. # Yet it throws not found when ID is longer than 62 characters and I don't know why. # To keep it safe, let's stick to the 62 characters limit. if id.size + postfix.size > 62 "#{id[0..(55 - postfix.size)]}#{Digest::MD5.hexdigest(id)[0..5]}#{postfix}" else "#{id}#{postfix}" end end |