Class: Sperm::RandomSource

Inherits:
Object
  • Object
show all
Includes:
Forwardable
Defined in:
lib/sperm/random_source.rb

Overview

Internal wrapper for Random instances and RandomSecure.

Instance Method Summary collapse

Constructor Details

#initialize(adaptee) ⇒ RandomSource


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sperm/random_source.rb', line 7

def initialize(adaptee)
  @adaptee = adaptee

  i(rand random_number).each do |method|
    next unless @adaptee.respond_to? method
    def_delegator :@adaptee, method, :rand
    return
  end

  fail ArgumentError, 'unsupported source of randomness'
end