Class: Unmagic::Passkeys::Rails::Routes::Mapping
- Inherits:
-
Object
- Object
- Unmagic::Passkeys::Rails::Routes::Mapping
- Defined in:
- lib/unmagic/passkeys/rails/routes.rb
Overview
Collects customization from the use_unmagic_passkeys block.
Instance Attribute Summary collapse
-
#credentials_as ⇒ Object
readonly
Returns the value of attribute credentials_as.
-
#credentials_path ⇒ Object
readonly
Returns the value of attribute credentials_path.
Instance Method Summary collapse
- #controller_for(flow) ⇒ Object
-
#controllers(map = nil) ⇒ Object
Re-point one or more flows at your own controllers (which should inherit from the matching engine base controller):.
-
#credentials_at(path:, as:) ⇒ Object
Where the management resource is mounted and how its route helpers are named (defaults to
/my/passkeysandmy_passkeys_path). - #draw?(flow) ⇒ Boolean
-
#initialize ⇒ Mapping
constructor
A new instance of Mapping.
-
#skip_controllers(*names) ⇒ Object
Skip drawing one or more flows:
skip_controllers :credentials.
Constructor Details
#initialize ⇒ Mapping
Returns a new instance of Mapping.
38 39 40 41 42 43 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 38 def initialize @controller_overrides = {} @skipped = [] @credentials_path = "my/passkeys" @credentials_as = "my_passkeys" end |
Instance Attribute Details
#credentials_as ⇒ Object (readonly)
Returns the value of attribute credentials_as.
36 37 38 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 36 def credentials_as @credentials_as end |
#credentials_path ⇒ Object (readonly)
Returns the value of attribute credentials_path.
36 37 38 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 36 def credentials_path @credentials_path end |
Instance Method Details
#controller_for(flow) ⇒ Object
71 72 73 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 71 def controller_for(flow) resolved_controllers.fetch(flow) end |
#controllers(map = nil) ⇒ Object
Re-point one or more flows at your own controllers (which should inherit from the matching engine base controller):
controllers sessions: "sessions", credentials: "my/passkeys"
49 50 51 52 53 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 49 def controllers(map = nil) return resolved_controllers if map.nil? map.each { |flow, controller| @controller_overrides[flow.to_sym] = controller.to_s } end |
#credentials_at(path:, as:) ⇒ Object
Where the management resource is mounted and how its route helpers
are named (defaults to /my/passkeys and my_passkeys_path).
62 63 64 65 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 62 def credentials_at(path:, as:) @credentials_path = path @credentials_as = as end |
#draw?(flow) ⇒ Boolean
67 68 69 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 67 def draw?(flow) !@skipped.include?(flow) end |
#skip_controllers(*names) ⇒ Object
Skip drawing one or more flows: skip_controllers :credentials.
56 57 58 |
# File 'lib/unmagic/passkeys/rails/routes.rb', line 56 def skip_controllers(*names) @skipped.concat(names.map(&:to_sym)) end |