Sha256: 2aab9fcac612440afd2ccf53497ecd2463516d9755720fc20541c4fd67a58ff0

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require "fido_metadata/verification_method_descriptor"

module FidoMetadata
  module Coercer
    class UserVerificationDetails
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fido_metadata-0.4.0 lib/fido_metadata/coercer/user_verification_details.rb
fido_metadata-0.3.0 lib/fido_metadata/coercer/user_verification_details.rb
fido_metadata-0.2.0 lib/fido_metadata/coercer/user_verification_details.rb
fido_metadata-0.1.0 lib/fido_metadata/coercer/user_verification_details.rb