Class: Unmagic::Passkeys::Holder::Config
- Inherits:
-
Object
- Object
- Unmagic::Passkeys::Holder::Config
- Defined in:
- lib/unmagic/passkeys/holder.rb
Overview
Configuration object yielded by has_passkeys when a block is given. Allows setting custom association options and ceremony option blocks.
Instance Attribute Summary collapse
-
#association_name ⇒ Object
Returns the value of attribute association_name.
-
#dependent ⇒ Object
Returns the value of attribute dependent.
Instance Method Summary collapse
-
#authentication_options(&block) ⇒ Object
Sets a block to evaluate in the holder’s context to produce additional authentication options.
-
#evaluate_authentication_options(record) ⇒ Object
Evaluates the request options block (if any) in the context of the given
record. -
#evaluate_registration_options(record) ⇒ Object
Evaluates the creation options block (if any) in the context of the given
record. -
#initialize(**options) ⇒ Config
constructor
A new instance of Config.
-
#registration_options(&block) ⇒ Object
Sets a block to evaluate in the holder’s context to produce additional creation options.
Constructor Details
#initialize(**options) ⇒ Config
Returns a new instance of Config.
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/unmagic/passkeys/holder.rb', line 75 def initialize(**) @association_name = .delete(:association_name) || :passkeys @dependent = .delete(:dependent) || :destroy if creation_opts = (Unmagic::Passkeys::WebAuthn::PublicKeyCredential::CreationOptions, ) @registration_options = (creation_opts) end if request_opts = (Unmagic::Passkeys::WebAuthn::PublicKeyCredential::RequestOptions, ) @authentication_options = (request_opts) end end |
Instance Attribute Details
#association_name ⇒ Object
Returns the value of attribute association_name.
73 74 75 |
# File 'lib/unmagic/passkeys/holder.rb', line 73 def association_name @association_name end |
#dependent ⇒ Object
Returns the value of attribute dependent.
73 74 75 |
# File 'lib/unmagic/passkeys/holder.rb', line 73 def dependent @dependent end |
Instance Method Details
#authentication_options(&block) ⇒ Object
Sets a block to evaluate in the holder’s context to produce additional authentication options.
config. { { user_verification: "required" } }
91 92 93 |
# File 'lib/unmagic/passkeys/holder.rb', line 91 def (&block) @authentication_options = block end |
#evaluate_authentication_options(record) ⇒ Object
Evaluates the request options block (if any) in the context of the given record. Called internally by the passkey_authentication_options method defined on the holder.
104 105 106 107 108 109 110 |
# File 'lib/unmagic/passkeys/holder.rb', line 104 def (record) if @authentication_options record.instance_exec(&@authentication_options) else {} end end |
#evaluate_registration_options(record) ⇒ Object
Evaluates the creation options block (if any) in the context of the given record. Called internally by the passkey_registration_options method defined on the holder.
114 115 116 117 118 119 120 |
# File 'lib/unmagic/passkeys/holder.rb', line 114 def (record) if @registration_options record.instance_exec(&@registration_options) else {} end end |
#registration_options(&block) ⇒ Object
Sets a block to evaluate in the holder’s context to produce additional creation options.
config. { { name: email, display_name: name } }
98 99 100 |
# File 'lib/unmagic/passkeys/holder.rb', line 98 def (&block) @registration_options = block end |