Class: FidoMetadata::Coercer::UserVerificationDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/fido_metadata/coercer/user_verification_details.rb

Class Method Summary collapse

Class Method Details

.coerce(values) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fido_metadata/coercer/user_verification_details.rb', line 8

def self.coerce(values)
  return unless values.is_a?(Array)
  return values if values.all? do |array|
    array.all? do |object|
      object.is_a?(VerificationMethodDescriptor)
    end
  end

  values.map do |array|
    array.map do |hash|
      object = FidoMetadata::VerificationMethodDescriptor.from_json(hash)

      if hash["baDesc"]
        object.ba_desc = FidoMetadata::BiometricAccuracyDescriptor.from_json(hash["baDesc"])
      end
      if hash["caDesc"]
        object.ca_desc = FidoMetadata::CodeAccuracyDescriptor.from_json(hash["caDesc"])
      end
      if hash["paDesc"]
        object.pa_desc = FidoMetadata::PatternAccuracyDescriptor.from_json(hash["paDesc"])
      end

      object
    end
  end
end