module ConditionalRandom
Constants
- VERSION
Public Class Methods
conditionalize(method_name)
click to toggle source
# File lib/conditional_random.rb, line 6 def self.conditionalize(method_name) # Raise error when method is not exists in SecureRandom SecureRandom.send(method_name) unless ::SecureRandom.respond_to?(method_name) define_singleton_method method_name do |*args, &block| begin random = ::SecureRandom.send(method_name, *args) end until block.nil? || (block && block.call(random)) random end end