The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
package TestApp::Model::Bar;

use Moose;

our @data;

extends 'Catalyst::Model';

with 'Catalyst::Model::Role::RunAfterRequest';

our $BPCI_GOT_RUN;

sub build_per_context_instance {
    my $self=shift;

    $BPCI_GOT_RUN = 1;

    return $self;
}


sub demonstrate {
    my $self = shift;
    $self->_run_after_request(
        sub { push( @data, "one" ); },
        sub { push( @data, "two" ); },
        sub { push @data, ref shift },
    );
}

1;