Module: Unmagic::Passkeys::Rails::Routes::Mapper
- Defined in:
- lib/unmagic/passkeys/rails/routes.rb
Overview
Mixed into ActionDispatch::Routing::Mapper.
Instance Method Summary collapse
Instance Method Details
#use_unmagic_passkeys(scope: nil, &block) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 83 def use_unmagic_passkeys(scope: nil, &block) mapping = Mapping.new mapping.instance_exec(&block) if block draw = lambda do if mapping.draw?(:sessions) resource :session, only: %i[new create destroy], controller: mapping.controller_for(:sessions) end if mapping.draw?(:credentials) resources :passkeys, only: %i[index create destroy], controller: mapping.controller_for(:credentials), path: mapping.credentials_path, as: mapping.credentials_as end end scope ? self.scope(scope, &draw) : instance_exec(&draw) end |