Sha256: 0b5e7341f75f39afc8e84163ba618de207f9fcf762a084f83a085c9f996dc44d
Contents?: true
Size: 694 Bytes
Versions: 4
Compression:
Stored size: 694 Bytes
Contents
require 'singleton' module Polytrix class ValidatorRegistry include Singleton def validators @validator ||= [] end class << self def validators instance.validators end def register(validator, scope = {}, &callback) validator = Validator.new(validator, scope, &callback) if block_given? validators << validator end def validators_for(challenge) selected_validators = validators.select { |v| v.should_validate? challenge } selected_validators.empty? ? [Polytrix.configuration.default_validator] : selected_validators end def clear validators.clear end end end end
Version data entries
4 entries across 4 versions & 1 rubygems