Class: Yoti::AgeVerification
- Inherits:
-
Object
- Object
- Yoti::AgeVerification
- 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
-
#age ⇒ Integer
readonly
The age that was that checked, as specified on Yoti Hub.
-
#attribute ⇒ Yoti::Attribute
readonly
The wrapped profile attribute.
-
#check_type ⇒ String
readonly
The type of age check performed, as specified on Yoti Hub.
-
#result ⇒ Boolean
readonly
Whether or not the profile passed the age check.
Instance Method Summary collapse
-
#initialize(attribute) ⇒ AgeVerification
constructor
A new instance of AgeVerification.
Constructor Details
#initialize(attribute) ⇒ AgeVerification
Returns a new instance of AgeVerification.
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
#age ⇒ Integer (readonly)
The age that was that checked, as specified on Yoti Hub.
37 38 39 |
# File 'lib/yoti/data_type/age_verification.rb', line 37 def age @age end |
#attribute ⇒ Yoti::Attribute (readonly)
The wrapped profile attribute.
Use this if you need access to the underlying list of Anchors.
14 15 16 |
# File 'lib/yoti/data_type/age_verification.rb', line 14 def attribute @attribute end |
#check_type ⇒ String (readonly)
The type of age check performed, as specified on Yoti Hub.
Among the possible values are ‘age_over’ and ‘age_under’.
30 31 32 |
# File 'lib/yoti/data_type/age_verification.rb', line 30 def check_type @check_type end |
#result ⇒ Boolean (readonly)
Whether or not the profile passed the age check.
21 22 23 |
# File 'lib/yoti/data_type/age_verification.rb', line 21 def result @result end |