Zapp::Type - Input/output handling for data types
version 0.005
package My::Type; use Mojo::Base 'Zapp::Type'; sub process_config( $self, $c, $form_value ) { # Return the $config_value } sub process_input( $self, $c, $config_value, $form_value ) { # Return the $input_value } sub task_input( $self, $config_value, $input_value ) { # Return the $task_value } sub task_output( $self, $config_value, $task_value ) { # Return the $input_value } __DATA__ @@ config.html.ep %# Form to configure the input @@ input.html.ep %# Form for the user to fill in @@ output.html.ep %# Template to display the value
This is the base class for Zapp types. Types are configured when building a plan, then filled out by the user when running the plan. Tasks then get the type's value as input, and can return a value of the given type.
The type value returned from "process_input" should contain all the information needed to use the value in a task. This does not need to be the actual content that tasks will use, but can be an identifier to look up that content.
For example, the Zapp::Type::File type stores a path relative to the application's home directory. When saving plans or starting runs, the file gets uploaded, saved to the home directory, and the path saved to the database. When a task needs the file, it gets the full path as a string.
Another example could be a map of user passwords in a config file. The type value could be the username, which would be stored in the database for the plan/run. Then when a task needed the password, it could be looked up using the username.
The application object. A Zapp object.
Get the field for configuration input. Reads the @@ config.html.ep file from the __DATA__ section of the type class.
@@ config.html.ep
__DATA__
Process the form value for configuring this type. Return the type config to be stored in the database.
Get the field for user input. Reads the @@ input.html.ep file from the __DATA__ section of the type class.
@@ input.html.ep
Process the form value when saving a run. Return the type value to be stored in the database.
Convert the type value stored in the database to the value used by the task.
Convert a value from a task's output into a type value to be stored in the database.
Show the value on the run page.
Doug Bell <preaction@cpan.org>
This software is copyright (c) 2021 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Zapp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Zapp
CPAN shell
perl -MCPAN -e shell install Zapp
For more information on module installation, please visit the detailed CPAN module installation guide.