NAME

Chloro::Result::Group - A result for a single group

VERSION

version 0.07

SYNOPSIS

    my $group_result = $resultset->result_for('group');

    for my $field_result ( $group_result->results() ) {
        print $field_result->field()->name() . ' = ' . $field_result->value();
    }

DESCRIPTION

This class represents the result for a single repetition of a group after processing user-submitted data.

A group result is like a miniature Chloro::ResultSet object, and shares some methods with that class, because it contains the results for more than one field.

METHODS

This class has the following methods:

Chloro::Result::Group->new()

The constructor accepts the following arguments:

  • group

    The Chloro::Group object for this result.

  • key

    The key associated with this group. This is a single value from the values in the associated Chloro::Group object's repetition_key field.

  • prefix

    The prefix for each field in this group. This will be the group name and key separated by a period ("."), something like "phone_number.42".

  • results

    This should be a hash reference where the keys are field names and the values are Chloro::Result::Field objects.

$result->results()

Returns a list of Chloro::Result::Field objects for the fields associated with this repetition of the group.

$result->result_for('field')

Given a field name, returns the Chloro::Result::Field object for that field. Note that for this API, you can simply pass the field's name without a group prefix.

$result->key()

Returns the key associated with this group result.

$result->prefix()

Returns the field prefix for this group result.

$result->is_valid()

This returns true if none of the fields in this group's result have any errors.

$result->key_value_pairs()

Returns the result as a key/value pair, where the keys are field names (without prefixes).

ROLES

This class does the Chloro::Role::Result and Chloro::Role::ResultSet role.

SUPPORT

Bugs may be submitted at http://rt.cpan.org/Public/Dist/Display.html?Name=Chloro or via email to bug-chloro@rt.cpan.org.

I am also usually active on IRC as 'autarch' on irc://irc.perl.org.

SOURCE

The source code repository for Chloro can be found at https://github.com/autarch/Chloro.

AUTHOR

Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the LICENSE file included with this distribution.