App-Standby

 view release on metacpan or  search on metacpan

lib/App/Standby/Service.pm  view on Meta::CPAN

package App::Standby::Service;
$App::Standby::Service::VERSION = '0.04';
BEGIN {
  $App::Standby::Service::AUTHORITY = 'cpan:TEX';
}
# ABSTRACT: Service Plugin baseclass

use 5.010_000;
use mro 'c3';
use feature ':5.10';

use Moose;
use namespace::autoclean;

# use IO::Handle;
# use autodie;
# use MooseX::Params::Validate;
# use Carp;
# use English qw( -no_match_vars );
# use Try::Tiny;

# extends ...
extends 'App::Standby';
# has ...
has 'name' => (
    'is'    => 'ro',
    'isa'   => 'Str',
    'required' => 1,
);

has 'description' => (
    'is'        => 'rw',
    'isa'       => 'Str',
    'required'  => 0,
);

has 'group_id' => (
    'is'    => 'ro',
    'isa'   => 'Int',
    'required' => 1,
);
# with ...
# initializers ...

# your code here ...
sub update {
    my $self = shift;
    my $user_ref = shift;

    # this base class does nothing here
    # subclasses should override this method
    # and update their services here ...
    my $new_user_ref = $self->_inject_per_user_config($user_ref);

    return $self->_update($new_user_ref);
}

sub _update {
    my $self = shift;
    my $user_ref = shift;
    # this base class does nothing here
    # subclasses should override this method
    # and update their services here ...
    return;
}

sub _inject_per_user_config {
    my $self = shift;
    my $user_ref = shift;

    my $sql = 'SELECT id,key,value FROM config_contacts WHERE contact_id = ?';
    my $sth = $self->dbh()->prepare($sql);
    if(!$sth) {
        $self->logger()->log( message => 'Failed to prepare SQL '.$sql.' w/ error: '.$self->dbh()->errstr, level => 'error', );
        return;
    }

    my @new_users = ();

    foreach my $user (@{$user_ref}) {



( run in 1.293 second using v1.01-cache-2.11-cpan-437f7b0c052 )