module SoarAuthenticationToken class TokenProvider def initialize(configuration) @configuration = configuration validate_configuration instantiate_provider end def fetch(request) @provider.fetch(request) end private def instantiate_provider @provider = Object::const_get(@configuration['authentication_token']['provider']) .new(@configuration['authentication_token']) end def validate_configuration raise 'authentication_token provider must be configured' if @configuration['authentication_token'].nil? or @configuration['authentication_token']['provider'].nil? end end end