Class: Yoti::AgeVerification

Inherits:
Object
  • Object
show all
Defined in:
lib/yoti/data_type/age_verification.rb

Overview

Wraps an ‘Age Verify/Condition’ attribute to provide behaviour specific to verifying someone’s age.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ AgeVerification

Returns a new instance of AgeVerification.

Parameters:

Raises:

  • (ArgumentError)


42
43
44
45
46
47
48
49
50
51
52
# File 'lib/yoti/data_type/age_verification.rb', line 42

def initialize(attribute)
  raise(ArgumentError, "'#{attribute.name}' is not a valid age verification") unless /^[^:]+:(?!.*:)[0-9]+$/.match?(attribute.name)

  @attribute = attribute

  split = attribute.name.split(':')
  @check_type = split[0]

  @age = split[1].to_i
  @result = attribute.value == 'true'
end

Instance Attribute Details

#ageInteger (readonly)

The age that was that checked, as specified on Yoti Hub.

Returns:

  • (Integer)


37
38
39
# File 'lib/yoti/data_type/age_verification.rb', line 37

def age
  @age
end

#attributeYoti::Attribute (readonly)

The wrapped profile attribute.

Use this if you need access to the underlying list of Anchors.

Returns:



14
15
16
# File 'lib/yoti/data_type/age_verification.rb', line 14

def attribute
  @attribute
end

#check_typeString (readonly)

The type of age check performed, as specified on Yoti Hub.

Among the possible values are ‘age_over’ and ‘age_under’.

Returns:

  • (String)


30
31
32
# File 'lib/yoti/data_type/age_verification.rb', line 30

def check_type
  @check_type
end

#resultBoolean (readonly)

Whether or not the profile passed the age check.

Returns:

  • (Boolean)


21
22
23
# File 'lib/yoti/data_type/age_verification.rb', line 21

def result
  @result
end