Sha256: 313242c36022f692387985548fff4adad2dfc650a712751772afd97e91b8b5be
Contents?: true
Size: 596 Bytes
Versions: 4
Compression:
Stored size: 596 Bytes
Contents
class BSON class ObjectId @@machine_id = NSData.MD5HexDigest(UIDevice.currentDevice.identifierForVendor.UUIDString.dataUsingEncoding(NSUTF8StringEncoding)).unpack("N")[0] @@mutex = Mutex.new @@counter = 0 def self.generate @@mutex.lock begin counter = @@counter = (@@counter + 1) % 0xFFFFFF ensure @@mutex.unlock rescue nil end process_thread_id = "#{Process.pid}#{Thread.current.object_id}".hash % 0xFFFF [Time.new.to_i, @@machine_id, process_thread_id, counter << 8].pack("N NX lXX NX").unpack("H*")[0] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
motion-yapper-0.1.0 | lib/yapper/bson.rb |
motion-yapper-0.0.3 | lib/yapper/bson.rb |
motion-yapper-0.0.2 | lib/yapper/bson.rb |
motion-yapper-0.0.1 | lib/yapper/bson.rb |