Module: Plutonium::Definition::InputAliases
- Defined in:
- lib/plutonium/definition/input_aliases.rb
Overview
What an as: on an input / display declaration MEANS, independent of any
view.
as: is a union: either an alias naming a built-in tag (:string,
:uppy, a String) OR a component Class rendered directly (see
UI::Component::ResolvesTags). A Class has no #to_sym, so
every "which alias is this?" question goes through InputAliases.resolve rather than
coercing as itself — the controller, the wizard, the generators and the
views all ask here.
Constant Summary collapse
- FILE_INPUT_TYPES =
The
as:values that render through the Uppy file-upload component — the single source of truth, so the form builder's tag aliases and the attachment detection in Wizard::Attachments.field? andPlutonium::Resource::Controller#attachment_input_keysnever drift. %i[uppy file attachment].freeze
Class Method Summary collapse
-
.file_input?(as) ⇒ Boolean
Whether an
as:renders as an attachment/file input. -
.resolve(as) ⇒ Symbol?
The Symbol form of a symbol/string
as:; nil for anything else, a component Class included, since it names no alias.
Class Method Details
.file_input?(as) ⇒ Boolean
Whether an as: renders as an attachment/file input.
32 33 34 |
# File 'lib/plutonium/definition/input_aliases.rb', line 32 def file_input?(as) FILE_INPUT_TYPES.include?(resolve(as)) end |
.resolve(as) ⇒ Symbol?
Returns the Symbol form of a symbol/string as:; nil for
anything else, a component Class included, since it names no alias.
The Symbol is NOT validated against the tags that actually exist —
callers compare it against the aliases they care about.
27 28 29 |
# File 'lib/plutonium/definition/input_aliases.rb', line 27 def resolve(as) as.to_sym if as.is_a?(Symbol) || as.is_a?(String) end |