class Apia::Definitions::Authenticator
Constants
- TYPES
Attributes
action[RW]
potential_errors[R]
scope_validator[RW]
type[RW]
Public Instance Methods
dsl()
click to toggle source
# File lib/apia/definitions/authenticator.rb, line 22 def dsl @dsl ||= DSLs::Authenticator.new(self) end
setup()
click to toggle source
# File lib/apia/definitions/authenticator.rb, line 17 def setup @id = id @potential_errors = [] end
validate(errors)
click to toggle source
# File lib/apia/definitions/authenticator.rb, line 26 def validate(errors) if @type.nil? errors.add self, 'MissingType', 'A type must be defined for authenticators' elsif !TYPES.include?(@type) errors.add self, 'InvalidType', "The type must be one of #{TYPES.join(', ')} (was: #{@type.inspect})" end if @action && !@action.is_a?(Proc) errors.add self, 'InvalidAction', 'The action provided must be a Proc' end @potential_errors.each_with_index do |error, index| unless error.respond_to?(:ancestors) && error.ancestors.include?(Apia::Error) errors.add self, 'InvalidPotentialError', "Potential error at index #{index} must be a class that inherits from Apia::Error" end end end