<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Test2::EventFacet::Info::Table;
use strict;
use warnings;

our $VERSION = '1.302199';

use Carp qw/confess/;

use Test2::Util::HashBase qw{-header -rows -collapse -no_collapse -as_string};

sub init {
    my $self = shift;

    confess "Table may not be empty" unless ref($self-&gt;{+ROWS}) eq 'ARRAY' &amp;&amp; @{$self-&gt;{+ROWS}};

    $self-&gt;{+AS_STRING} ||= '&lt;TABLE NOT DISPLAYED&gt;';
}

sub as_hash { my $out = +{%{$_[0]}}; delete $out-&gt;{as_string}; $out }

sub info_args {
    my $self = shift;

    my $hash = $self-&gt;as_hash;
    my $desc = $self-&gt;as_string;

    return (table =&gt; $hash, details =&gt; $desc);
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Test2::EventFacet::Info::Table - Intermediary representation of a table.

=head1 DESCRIPTION

Intermediary representation of a table for use in specialized
L&lt;Test::API::Context&gt; methods which generate L&lt;Test2::EventFacet::Info&gt; facets.

=head1 SYNOPSIS

    use Test2::EventFacet::Info::Table;
    use Test2::API qw/context/;

    sub my_tool {
        my $ctx = context();

        ...

        $ctx-&gt;fail(
            $name,
            "failure diag message",
            Test2::EventFacet::Info::Table-&gt;new(
                # Required
                rows =&gt; [['a', 'b'], ['c', 'd'], ...],

                # Strongly Recommended
                as_string =&gt; "... string to print when table cannot be rendered ...",

                # Optional
                header =&gt; ['col1', 'col2'],
                collapse =&gt; $bool,
                no_collapse =&gt; ['col1', ...],
            ),
        );

        ...

        $ctx-&gt;release;
    }

    my_tool();

=head1 ATTRIBUTES

=over 4

=item $header_aref = $t-&gt;header()

=item $rows_aref = $t-&gt;rows()

=item $bool = $t-&gt;collapse()

=item $aref = $t-&gt;no_collapse()

The above are all directly tied to the table hashref structure described in
L&lt;Test2::EventFacet::Info&gt;.

=item $str = $t-&gt;as_string()

This returns the string form of the table if it was set, otherwise it returns
the string C&lt;&lt; "&lt;TABLE NOT DISPLAYED&gt;" &gt;&gt;.

=item $href = $t-&gt;as_hash()

This returns the data structure used for tables by L&lt;Test2::EventFacet::Info&gt;.

=item %args = $t-&gt;info_args()

This returns the arguments that should be used to construct the proper
L&lt;Test2::EventFacet::Info&gt; structure.

    return (table =&gt; $t-&gt;as_hash(), details =&gt; $t-&gt;as_string());

=back

=head1 SOURCE

The source code repository for Test2 can be found at
L&lt;https://github.com/Test-More/test-more/&gt;.

=head1 MAINTAINERS

=over 4

=item Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;

=back

=head1 AUTHORS

=over 4

=item Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;

=back

=head1 COPYRIGHT

Copyright 2020 Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See L&lt;https://dev.perl.org/licenses/&gt;

=cut
</pre></body></html>