Balancer/Command/Add/Backend.pm

filter: Statementstmt 70.5% 12 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 0.0% 0 / 2 totaltotal 58.3% 14 / 24 CC 1 SCAR 4.7
CC
1
Cov
71%
__ANON__
2.0
ordinary_args
2.0
run
2.0
CRAP 1.6
« Balancer/Command/Add/Host.pm ↑ Summary Balancer/Model/Host.pm »
1 package HTTP::Balancer::Command::Add::Backend;
2 1 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 with qw(HTTP::Balancer::Role::Command);
5  
6 has name => (
7 is => "rw",
8 traits => [ 'NoGetopt' ],
9 0 ▶ default => sub { shift->argv(2) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
10 1 );
11  
12 1 has host => (
13 is => "rw",
14 isa => "Str",
15 required => 1,
16 traits => ['Getopt'],
17 cmd_aliases => 'h',
18 documentation => "the virtual host this backend belongs to",
19 );
20  
21 1 has address => (
22 is => "rw",
23 isa => "Str",
24 required => 1,
25 traits => ['Getopt'],
26 cmd_aliases => 'a',
27 documentation => "the address of this backend",
28 );
29  
30 1 has port => (
31 is => "rw",
32 isa => "Num",
33 traits => ['Getopt'],
34 cmd_aliases => 'p',
35 default => "80",
36 documentation => "the port of this backend listens to. default: 80",
37 );
38  
39 0 ▶sub ordinary_args {
Subroutine ordinary_args: not called CC=1 SCAR=6.9
Pod undocumented
40 0 qw(name)
41 };
42  
43 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
44 0 my ($self, ) = @_;
45  
46 0 my $host = $self->model("Host")->find(name => $self->host);
47  
48 0 $self->model("Backend")
49 ->new(
50 name => $self->name,
51 address => $self->address,
52 port => $self->port,
53 host_id => $host->id,
54 )
55 ->save;
56 }
57  
58 1 1;
« Balancer/Command/Add/Host.pm ↑ Summary Balancer/Model/Host.pm »