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

NAME

POEx::Trait::ExtraInitialization - Provides a initialization behaviors for POEx::Role::SessionInstantiation objects

VERSION

version 0.092720

SYNOPSIS

    class My::Session
    {
        use POEx::Trait::ExtraInitialization;
        use POEx::Role::SessionInstantiation
            traits => [ 'POEx::Trait::ExtraInitialization' ];

        with 'POEx::Role::SessionInstantiation';

        ....
    }

    My::Session->new(initialization_method => $some_external_coderef);

    POE::Kernel->run();

DESCRIPTION

POEx::Trait::ExtraInitialization is a simple trait for SessionInstantiation to enable passing in an arbitrary coderef for execution just after other normal initialization

This role could also be applied upon an instance but there are some caveats. Your class must also consume POEx::Trait::DeferredRegistration, which will prevent instances from immediately being registered with POE after BUILD. Otherwise, _start has already been fired, and too late for extra initialization to execute (BUILD is advised by SessionInstantiate to do Session allocation within POE which immediately calls _start).

ATTRIBUTES

initialization_method is: ro, isa: CodeRef, required: 1

This attribute stores the code ref that will be called as method on the composed class.

METHODS

after _start

_start is advised to run the initialization method during the 'after' phase. The method receives no arguments other than the invocant

AUTHOR

  Nicholas Perez <nperez@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2009 by Infinity Interactive.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007