@api private
Generate object id data for a given time using the provided counter.
# File lib/moped/bson/object_id.rb, line 113 def generate(time, counter = 0) process_thread_id = "#{Process.pid}#{Thread.current.object_id}".hash % 0xFFFF [time, @machine_id, process_thread_id, counter << 8].pack("N NX lXX NX") end
Return object id data based on the current time, incrementing the object id counter.
# File lib/moped/bson/object_id.rb, line 101 def next @mutex.lock begin counter = @counter = (@counter + 1) % 0xFFFFFF ensure @mutex.unlock rescue nil end generate(Time.new.to_i, counter) end
Generated with the Darkfish Rdoc Generator 2.