Module: StrokeDB::Util

Defined in:
lib/strokedb/util.rb,
lib/strokedb/util/uuid.rb,
lib/strokedb/util/java_util.rb

Defined Under Namespace

Classes: CircularReferenceCondition

Constant Summary collapse

RAW_UUID_SIZE =
random_uuid_raw.size
FORMATTED_UUID_SIZE =
random_uuid.size

Class Method Summary collapse

Class Method Details

.catch_circular_reference(value, name = 'StrokeDB.reference_stack') ⇒ Object



22
23
24
25
26
27
28
# File 'lib/strokedb/util.rb', line 22

def catch_circular_reference(value,name = 'StrokeDB.reference_stack')
  stack = Thread.current[name] ||= []
  raise CircularReferenceCondition if stack.find{|v| value == v}
  stack << value
  yield
  stack.pop
end

.random_uuidObject



5
6
7
# File 'lib/strokedb/util/java_util.rb', line 5

def self.random_uuid
  java.util.UUID.random_uuid.to_s
end

.random_uuid_rawObject



8
9
10
11
# File 'lib/strokedb/util/java_util.rb', line 8

def self.random_uuid_raw
  uuid = java.util.UUID.random_uuid
  [uuid.most_significant_bits, uuid.least_significant_bits].pack("Q2")
end