Sha256: 66ccd99c5270e9624501644431f93fec99846d81871fc405f17a9e16378b572b

Contents?: true

Size: 423 Bytes

Versions: 1

Compression:

Stored size: 423 Bytes

Contents

module Sperm
  # Internal wrapper for Random instances and RandomSecure.
  #
  class RandomSource
    include Forwardable

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sperm-0.1.1 lib/sperm/random_source.rb