File Coverage

blib/lib/Apache/BalancerManager/Member.pm
Criterion Covered Total %
statement 9 9 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 3 3 100.0
total 18 18 100.0


line stmt bran cond sub pod time code
1             package Apache::BalancerManager::Member;
2             $Apache::BalancerManager::Member::VERSION = '0.002000';
3             # ABSTRACT: ClientSide representation of Apache BalancerManager Member
4              
5 1     1   7 use Moo;
  1         2  
  1         10  
6              
7             has $_ => ( is => 'rw' ) for qw(
8             load_factor
9             lb_set
10             route
11             route_redirect
12             status
13             );
14              
15             has $_ => ( is => 'ro' ) for qw(
16             times_elected
17             location
18             );
19              
20             has $_ => (
21             is => 'ro',
22             coerce => sub {$_[0] =~ s/\s//g; $_[0]}
23             ) for qw(from to);
24              
25             has manager => (
26             is => 'ro',
27             required => 1,
28             weak_ref => 1,
29             handles => {
30             _balancer_name => 'name',
31             _nonce => 'nonce',
32             _url => 'url',
33             _get => '_get',
34             _post => '_post',
35             },
36             );
37              
38 1     1 1 9 sub disable { $_[0]->status(0) }
39 1     1 1 3725 sub enable { $_[0]->status(1) }
40              
41             sub update {
42 4     4 1 43035 my $self = shift;
43              
44 4         159 my $uri = URI->new($self->_url);
45 4 100       861 my $form = {
46             w_status_D => ( $self->status ? 0 : 1 ),
47             w_status_I => 0,
48             w_status_N => 0,
49             w_status_H => 0,
50             w_status_R => 0,
51             w_status_S => 0,
52             w_lf => $self->load_factor,
53             w_ls => $self->lb_set,
54             w_wr => $self->route,
55             w_rr => $self->route_redirect,
56             w => $self->location,
57             b => $self->_balancer_name,
58             nonce => $self->_nonce,
59             };
60 4         686 $self->_post($uri, $form);
61             }
62              
63             1;
64              
65             __END__