| Class | ActiveRecord::ConnectionAdapters::TwelveByteKey |
| In: |
vendor/rails/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb
|
| Parent: | String |
From EOF Documentation.… buffer should have space for EOUniqueBinaryKeyLength (12) bytes. Assigns a world-wide unique ID made up of: < Sequence [2], ProcessID [2] , Time [4], IP Addr [4] >
# File vendor/rails/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb, line 60
60: def initialize(string = nil)
61: # Generate a unique key
62: if string.nil?
63: new_key = replace('_' * 12)
64:
65: new_key[0..1] = self.class.key_sequence_component
66: new_key[2..3] = self.class.key_pid_component
67: new_key[4..7] = self.class.key_time_component
68: new_key[8..11] = self.class.key_ip_component
69: new_key
70: else
71: if string.size == 24
72: string.gsub!(/[[:xdigit:]]{2}/) { |x| x.hex.chr }
73: end
74: raise "string is not 12 bytes long" unless string.size == 12
75: super(string)
76: end
77: end