Module: ActiveRecord::RandomID::Generator

Defined in:
lib/vex/active_record/random_id.rb

Class Method Summary collapse

Class Method Details

.integerObject


8
9
10
11
# File 'lib/vex/active_record/random_id.rb', line 8

def self.integer
  # This gives us 31 bits of random data.
  ActiveSupport::SecureRandom.random_number 0x7fffffff
end

.largeObject


13
14
15
16
# File 'lib/vex/active_record/random_id.rb', line 13

def self.large
  # This gives us 63 bits of random data.
  ActiveSupport::SecureRandom.random_number 0x7fffffffffffffff
end

.stringObject


3
4
5
6
# File 'lib/vex/active_record/random_id.rb', line 3

def self.string
  # This puts 40 random bits into a string.
  ActiveSupport::SecureRandom.random_number(0xffffffffff).to_s(36)
end