class FFaker::UniqueUtils
def self.clear
def self.clear ObjectSpace.each_object(self, &:clear) end
def add_results_to_hash(name, *arguments)
def add_results_to_hash(name, *arguments) @max_retries.times do result = @generator.send(name, *arguments) next if @previous_results[[name, arguments]].include?(result) @previous_results[[name, arguments]] << result return result end raise RetryLimitExceeded end
def clear
def clear @previous_results.clear end
def initialize(generator, max_retries)
def initialize(generator, max_retries) @generator = generator @max_retries = max_retries @previous_results = Hash.new { |hash, key| hash[key] = Set.new } end
def method_missing(name, *arguments)
def method_missing(name, *arguments) @generator.respond_to?(name) ? add_results_to_hash(name, *arguments) : super end
def respond_to_missing?(method_name, include_private = false)
def respond_to_missing?(method_name, include_private = false) super end