Module: Plutonium::Wizard::Attachments
- Defined in:
- lib/plutonium/wizard/attachments.rb
Overview
A wizard's view of Attachments.
The staging and revival machinery moved out when async interactions needed the same thing: both hold an attachment as a bare string while the work is in flight, and neither has a model to hang it off until the work lands. None of that was ever wizard-specific — only the two things left here are.
This stays the wizard's entry point rather than having wizard code reach
for the shared module directly, so the backend: default keeps being the
wizard's own setting without every call site remembering to pass it.
Constant Summary collapse
- Resolved =
Kept as a constant here because it is part of this module's published surface: a host rendering a staged attachment may name
Wizard::Attachments::Resolved. Plutonium::Attachments::Resolved
Class Method Summary collapse
-
.attachment_backend ⇒ Symbol
The server-side staging backend for wizard attachments: the wizard's own setting, else the global default.
-
.field?(input_options) ⇒ Boolean
Whether a step input renders as an attachment (its
as:is a file alias), so its staged token should be resolved for display. - .resolve(value) ⇒ Object
- .stage_upload(value, backend: nil, uploader: nil) ⇒ Object
- .validation_errors(value, backend: nil, uploader: nil) ⇒ Object
Class Method Details
.attachment_backend ⇒ Symbol
The server-side staging backend for wizard attachments: the wizard's own setting, else the global default.
Layered rather than replacing: an app that sets only
config.attachment_backend gets it here too, and one that sets
config.wizards.attachment_backend still overrides it for wizards alone.
42 43 44 45 |
# File 'lib/plutonium/wizard/attachments.rb', line 42 def Plutonium.configuration.wizards. || Plutonium::Attachments.default_backend end |
.field?(input_options) ⇒ Boolean
Whether a step input renders as an attachment (its as: is a file alias),
so its staged token should be resolved for display. Keys off the form's
canonical file-input alias set, so the two never drift.
Wizard-only: it reads a STEP INPUT's options, which is a shape nothing outside the wizard DSL has.
29 30 31 32 |
# File 'lib/plutonium/wizard/attachments.rb', line 29 def field?() as = &.dig(:options, :as) || &.dig(:as) Plutonium::Definition::InputAliases.file_input?(as) end |
.resolve(value) ⇒ Object
48 |
# File 'lib/plutonium/wizard/attachments.rb', line 48 def resolve(value) = Plutonium::Attachments.resolve(value) |
.stage_upload(value, backend: nil, uploader: nil) ⇒ Object
51 52 53 |
# File 'lib/plutonium/wizard/attachments.rb', line 51 def stage_upload(value, backend: nil, uploader: nil) Plutonium::Attachments.stage_upload(value, backend: backend || , uploader:) end |
.validation_errors(value, backend: nil, uploader: nil) ⇒ Object
56 57 58 |
# File 'lib/plutonium/wizard/attachments.rb', line 56 def validation_errors(value, backend: nil, uploader: nil) Plutonium::Attachments.validation_errors(value, backend: backend || , uploader:) end |