Module: ConcernsOnRails::Support::RandomValue
- Defined in:
- lib/concerns_on_rails/support/random_value.rb
Overview
Shared random-value generation used by Hashable (:custom) and Tokenizable (:alphanumeric / :numeric). Samples ‘length` characters uniformly from `alphabet` using SecureRandom.
Class Method Summary collapse
Class Method Details
.from_alphabet(alphabet, length) ⇒ Object
11 12 13 |
# File 'lib/concerns_on_rails/support/random_value.rb', line 11 def from_alphabet(alphabet, length) Array.new(length) { alphabet[SecureRandom.random_number(alphabet.size)] }.join end |