Module: DaphneUtil::IdGenerator

Defined in:
lib/daphne_util/id_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.generate(*seed) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/daphne_util/id_generator.rb', line 4

def self.generate(*seed)
  seed_string = seed.compact.join("-")
  hashes = (0..4).to_a.map {|x| Digest::MD5.hexdigest("client_id=#{seed_string}#{DaphneUtil.salt}#{x}")}

  prefix = DaphneUtil.prefix(seed[0])

  [
    prefix,
    hashes[0][4..11],
    hashes[1][8..11],
    hashes[2][12..15],
    hashes[3][16..19],
    hashes[4][20..31],
  ].join("-")
end

Instance Method Details

#generate(seed) ⇒ Object



20
21
22
# File 'lib/daphne_util/id_generator.rb', line 20

def generate(seed)
  DaphneUtil::IdGenerator.generate(seed)
end