Class: Synthra::Types::TechnologyInternet::MongodbObjectId

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/technology_internet/formats.rb

Overview

MongodbObjectId type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



129
130
131
# File 'lib/synthra/types/technology_internet/formats.rb', line 129

def generate_edge(rng, context, args)
  ["000000000000000000000000", "ffffffffffffffffffffffff"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



133
134
135
# File 'lib/synthra/types/technology_internet/formats.rb', line 133

def generate_invalid(rng, context, args)
  [nil, "not an id", "invalid", [], {}].sample(random: rng.instance_variable_get(:@random))
end

#generate_random(rng, context, args) ⇒ Object



123
124
125
126
127
# File 'lib/synthra/types/technology_internet/formats.rb', line 123

def generate_random(rng, context, args)
  # MongoDB ObjectID is 24 hex characters
  chars = ('0'..'9').to_a + ('a'..'f').to_a
  24.times.map { rng.sample(chars) }.join
end