Class: Wonk::PolicyValidators::Validator
- Inherits:
-
Object
- Object
- Wonk::PolicyValidators::Validator
show all
- Defined in:
- lib/wonk/policy_validators/validator.rb
Instance Method Summary
collapse
Constructor Details
#initialize(parameters) ⇒ Validator
Returns a new instance of Validator.
6
7
8
|
# File 'lib/wonk/policy_validators/validator.rb', line 6
def initialize(parameters)
raise "#{self.class.name} can't be directly initialized."
end
|
Instance Method Details
#authenticate_from_submission(submission) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/wonk/policy_validators/validator.rb', line 14
def authenticate_from_submission(submission)
if !submission.key?(:authentication_type)
ValidatorResult.new(successful: false, environment: {})
else
if submission[:authentication_type] == validator_name
begin
do_authenticate(submission)
rescue ValidatorError => err
Wonk.logger.warn "Validator failed with reason: #{err.message}"
ValidatorResult.new(successful: false, environment: {})
rescue StandardError => err
Wonk.logger.error "Unrecognized error rescued from validator #{self.class.name}: #{err}"
ValidatorResult.new(successful: false, environment: {})
end
else
ValidatorResult.new(successful: false, environment: {})
end
end
end
|
#do_authenticate(submission) ⇒ Object
34
35
36
|
# File 'lib/wonk/policy_validators/validator.rb', line 34
def do_authenticate(submission)
raise "#{self.class.name}#do_authenticate(request) must be implemented."
end
|
#validator_name ⇒ Object
10
11
12
|
# File 'lib/wonk/policy_validators/validator.rb', line 10
def validator_name
raise "#{self.class.name}#validator_name must be implemented."
end
|