App-Environ
view release on metacpan or search on metacpan
0.22 Sat Apr 1 16:00:22 MSK 2017
- README.pod replaced by README.md.
0.20 Thu Feb 16 14:51:05 MSK 2017
- Added handling of environment variable APPCONF_EXPORT_ENV.
- Added description for all environment variables used by
App::Environ::Config.
- Added README.pod file instead of README file.
0.18 Thu Dec 8 18:06:30 MSK 2016
- FEATURE: Changed concept of asynchronous processing.
Backward compatible was broken.
0.16 Thu Dec 1 17:34:05 MSK 2016
- BUGFIX: Fixed issue with repeatable initialization/finalization in
App::Environ::Config.
0.14 Wed Nov 30 17:07:55 MSK 2016
- BUGFIX: Fixed error handling for asynchronous mode.
0.12 Fri Nov 25 12:09:30 MSK 2016
- Removed garbage from example.
0.10 Fri Nov 25 12:03:05 MSK 2016
- Fixes in POD.
- Light refactoring.
0.08 Wed Nov 23 17:17:05 MSK 2016
- FEATURE: Added ability to handle errors in asynchronous mode.
- BUGFIX: Fixed handling of unknown events in asynchronous mode.
- Improved POD.
- Improved test.
0.06 Tue Nov 22 12:22:40 MSK 2016
- Removed "finalize:r" handler from App::Environ.
- Refactoring.
0.04 Mon Nov 21 14:30:20 MSK 2016
- Added "finalize:r" handler in App::Environ.
- Do not die if handler has already registered.
# handling...
},
);
## send\_event( $event \[, @args \] \[, $cb->( \[ $err \] ) \] )
Sends specified event to App::Environ. All handlers registered for this event
will be processed. Arguments specified in `send_event` method will be passed
to event handlers. If the callback is passed in the last argument, event
handlers will be processed in asynchronous mode.
App::Environ->send_event( 'initialize', qw( foo bar ) );
App::Environ->send_event( 'pre_finalize:r'
sub {
my $err = shift;
if ( defined $err ) {
# error handling...
lib/App/Environ.pm view on Meta::CPAN
# handling...
},
);
=head2 send_event( $event [, @args ] [, $cb->( [ $err ] ) ] )
Sends specified event to App::Environ. All handlers registered for this event
will be processed. Arguments specified in C<send_event> method will be passed
to event handlers. If the callback is passed in the last argument, event
handlers will be processed in asynchronous mode.
App::Environ->send_event( 'initialize', qw( foo bar ) );
App::Environ->send_event( 'pre_finalize:r'
sub {
my $err = shift;
if ( defined $err ) {
# error handling...
t/01-event-processing.t view on Meta::CPAN
is( $t_bar_inst->{reloads}, 1, 'reload; Bar' );
return;
}
sub t_async_call {
my $t_done;
App::Environ->send_event( 'pre_finalize:r', undef, sub { $t_done = 1 } );
is( $t_done, 1, 'asynchronous event' );
return;
}
sub t_unknown_event {
lives_ok {
App::Environ->send_event('unknown');
}
'unknown event';
return;
}
sub t_handling_error {
eval { App::Environ->send_event( 'reload', 1 ) };
my $t_err_sync = $@;
is( $t_err_sync, "Some error.\n", 'handling error; synchronous' );
my $t_err_async;
App::Environ->send_event( 'pre_finalize:r', 1,
sub { $t_err_async = shift } );
is( $t_err_async, "Some error.", 'handling error; asynchronous' );
return;
}
sub t_finalize {
App::Environ->send_event('finalize:r');
like(
exception {
my $t_foo_inst = Foo->instance;
( run in 0.605 second using v1.01-cache-2.11-cpan-05444aca049 )