Activator
view release on metacpan or search on metacpan
lib/Activator/Config.pm view on Meta::CPAN
=back
=head1 METHODS
=cut
sub new {
my ( $pkg ) = @_;
my $self = bless( {
REGISTRY => Activator::Registry->new(),
ARGV_EXTRA => {},
ARGV => undef,
BAREWORDS => undef,
}, $pkg);
$self->_init_StrongSingleton();
return $self;
}
lib/Activator/DB.pm view on Meta::CPAN
use Exception::Class::TryCatch;
use Data::Dumper;
use Time::HiRes qw( gettimeofday tv_interval );
use Scalar::Util;
use base 'Class::StrongSingleton';
# constructor: implements singleton
sub new {
my ( $pkg, $conn_alias ) = @_;
my $self = bless( {}, $pkg);
$self->_init_StrongSingleton();
return $self;
}
# connect to a db alias
# initializes singleton object returned from new()
# Args:
# $conn_alias => the alias to use as configured in the registry
lib/Activator/DB.pm view on Meta::CPAN
# explode args for a db query sub
sub _explode {
my ( $pkg, $bindref, $args ) = @_;
my $bind = $bindref || [];
my $self = $pkg;
my $connect_to = $args->{connect};
# handle static calls
if ( !( Scalar::Util::blessed($self) && $self->isa( 'Activator::DB') ) ) {
if ( $connect_to ) {
$self = Activator::DB->connect( $connect_to );
}
else {
Activator::Exception::DB->throw( 'connect', 'missing');
}
}
# static or OO, respect the connect
if ( $connect_to ) {
lib/Activator/Dictionary.pm view on Meta::CPAN
Creates a dictionary object. Not very useful, as all it does is create
an uninitialized instance of an Activator::Dictionary object.
=cut
# Contstructor. Implements singleton.
sub new {
my ( $pkg, $lang ) = @_;
my $self = bless( { LOG_LEVEL_FOR_FILE_LOAD => 'WARN' }, $pkg);
$self->_init_StrongSingleton();
return $self;
}
sub _init_config {
my ($self) = @_;
# old config format
lib/Activator/Emailer.pm view on Meta::CPAN
=back
=cut
sub new {
my ( $pkg, %args ) = @_;
my $config = Activator::Registry->get( 'Activator::Emailer' ) || {};
my $self = Hash::Merge::merge( \%args, $config );
bless ( $self ), $pkg;
$self->{attachments} = [];
my $args = { mailer => $self->{mailer_type} };
if ( keys %{ $self->{mailer_args} } ) {
$args->{mailer_args} = [ %{ $self->{mailer_args} } ];
}
$self->{sender} = Email::Send->new( $args );
return $self;
}
lib/Activator/Log.pm view on Meta::CPAN
See also the full description of this technique in "Using
Log::Log4perl from wrapper classes" in the Log4perl FAQ.
=cut
# constructor: implements singleton
sub new {
my ( $pkg, $level ) = @_;
my $self = bless( { }, $pkg);
$self->_init_StrongSingleton();
if ( Log::Log4perl->initialized() ) {
# do nothing, logger already set
}
else {
# old config format
my $config =
lib/Activator/Options.pm view on Meta::CPAN
=head2 new()
Constructor: implements singleton. Not very useful. Use L<get_opts()>.
=cut
sub new {
my ( $pkg ) = @_;
my $self = bless( {
REGISTRY => Activator::Registry->new(),
ARGV_EXTRA => {},
ARGV => undef,
BAREWORDS => undef,
}, $pkg);
$self->_init_StrongSingleton();
return $self;
}
lib/Activator/Pager.pm view on Meta::CPAN
$total - total items available
Returns:
$self
Sample:
n == highest possible offset
p == highest possbile page
$self = bless( {
next_offset => 5, -- offset of next page ( 0..n ) or undef if you are
on last page
set_size => 5, -- constructor argument
prev_offset => 0, -- offset of previous page ( 0..n ) or undef if you
are on first page
cur_page => 1, -- the current page number of $offset
last_page => 21, -- the last page page for the total passed in ( 1..p )
last_offset => 100,-- the last possible offset based on number pages ( 0..n )
total => 103, -- constructor argument
next_page => 2, -- the next possible page ( 1..p ) or undef if on
lib/Activator/Pager.pm view on Meta::CPAN
}, Activator::Pager );
NOTE: we need to document the assuption of offset not being $to
=cut
sub new {
my ($pkg, $offset, $page_size, $set_size, $total) = @_;
my $self = bless {}, $pkg;
$offset ||= 0;
if( $page_size < 0 ) { $page_size = $set_size }
$self->{offset} = $offset;
$self->{page_size} = $page_size;
$self->{set_size} = $set_size;
$self->{total} = $total;
lib/Activator/Registry.pm view on Meta::CPAN
specified by C<$ENV{ACT_REG_YAML_FILE}>, then C<$yaml_file>. If
neither are valid YAML files, you will have an object with an empty
registry. If the registry has already been loaded, DOES NOT RELOAD it.
use L</reload()> for that.
=cut
sub new {
my ( $pkg, $yaml_file ) = @_;
my $self = bless( {
DEFAULT_REALM => 'default',
REGISTRY => { },
# TODO: consider using this custom precedence:
# SAFE_LEFT_PRECEDENCE =>
# {
# 'SCALAR' => {
# 'SCALAR' => sub { $_[0] },
# 'ARRAY' => &die_array_scalar,
# 'HASH' => &die_hash_scalar,
t/Exception.t view on Meta::CPAN
ok( $err eq 'DbObj DbCode DbExtra', 'subclass exception inherits fields' );
try eval {
die "text failure";
};
catch $err;
ok( $err, "Can catch random die");
my $str = $err;
chomp $str;
ok( $err =~ /^text failure/, "random die caught");
ok( $err->isa('Exception::Class::Base'), 'random die is a blessed Exception obj');
( run in 1.152 second using v1.01-cache-2.11-cpan-de7293f3b23 )