NAME

Zapp::Type - Input/output handling for data types

VERSION

version 0.005

SYNOPSIS

    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

DESCRIPTION

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.

Type Value

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.

SEE ALSO

ATTRIBUTES

app

The application object. A Zapp object.

METHODS

config_field

Get the field for configuration input. Reads the @@ config.html.ep file from the __DATA__ section of the type class.

process_config

Process the form value for configuring this type. Return the type config to be stored in the database.

input_field

Get the field for user input. Reads the @@ input.html.ep file from the __DATA__ section of the type class.

process_input

Process the form value when saving a run. Return the type value to be stored in the database.

task_input

Convert the type value stored in the database to the value used by the task.

task_output

Convert a value from a task's output into a type value to be stored in the database.

display_value

Show the value on the run page.

AUTHOR

Doug Bell <preaction@cpan.org>

COPYRIGHT AND LICENSE

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.