Sha256: 03d6dce9ac48f2a2bd13f695e8a9d666018d2c1d63c6aed34af5ded4cca0ec23

Contents?: true

Size: 661 Bytes

Versions: 6

Compression:

Stored size: 661 Bytes

Contents

# frozen_string_literal: true

require "awrence"

module WebAuthn
  class PublicKeyCredential
    class Entity
      attr_reader :name

      def initialize(name:)
        @name = name
      end

      def as_json
        to_hash.to_camelback_keys
      end

      private

      def to_hash
        hash = {}

        attributes.each do |attribute_name|
          value = send(attribute_name)

          if value.respond_to?(:as_json)
            value = value.as_json
          end

          if value
            hash[attribute_name] = value
          end
        end

        hash
      end

      def attributes
        [:name]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
webauthn-3.1.0 lib/webauthn/public_key_credential/entity.rb
webauthn-3.0.0 lib/webauthn/public_key_credential/entity.rb
webauthn-3.0.0.alpha2 lib/webauthn/public_key_credential/entity.rb
webauthn-2.5.2 lib/webauthn/public_key_credential/entity.rb
webauthn-2.5.1 lib/webauthn/public_key_credential/entity.rb
webauthn-2.5.0 lib/webauthn/public_key_credential/entity.rb