OpenInteract2::Config::Initializer is a Perl module for observable configuration initialization events.
SYNOPSIS
# Add an initializer in your package.conf
name mypackage
version 1.10
...
config_watcher OpenInteract2::MyInitializerSpops
config_watcher OpenInteract2::MyInitializerAction
# And the code in our package -- we'll dynamically add a rule from
# 'My::Googlable' to a class where 'is_googlable' is set to 'yes'
package OpenInteract2::MyInitializerSpops;
use strict;
sub update {
my ( $class, $type, $config ) = @_;
return unless ( $type eq 'spops' );
if ( $config->{is_googlable} eq 'yes' ) {
push @{ $config->{rules_from} }, 'My::Googable';
}
}
# Add a configuration observer in the server configuration
[config_watcher]
class = OpenInteract2::MyInitializerAction
# and in the class we'll dynamically add a filter to an action where
# 'is_googlable' is 'yes'
package OpenInteract2::MyInitializerAction;
use strict;
use OpenInteract2::Context qw( CTX );
sub update {
my ( $class, $type, $config ) = @_;
return unless ( $type eq 'action' );
if ( 'yes' eq lc $config->{is_googlable} ) {
CTX->map_observer( google => $config->{class} );
}
}
Product's homepage
Requirements:
· Perl