| 1 | package Net::OpenStack::Client::Base; | ||||||||||||||||||||
| 2 | 7 | $Net::OpenStack::Client::Base::VERSION = '0.1.4'; | |||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | Net::OpenStack::Client::Base provides basic class structure for Net::OpenStack::Client | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =head2 Public methods | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =over | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | =item new | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | sub new | ||||||||||||||||||||
| 20 | 9 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||
| 21 | 9 | my $this = shift; | |||||||||||||||||||
| 22 | 9 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 23 | 9 | my $self = { | |||||||||||||||||||
| 24 | versions => {}, | ||||||||||||||||||||
| 25 | services => {}, | ||||||||||||||||||||
| 26 | }; # here, it gives a reference on a hash | ||||||||||||||||||||
| 27 | 9 | bless $self, $class; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 9 | ▶ | return $self->_initialize(@_) ? $self : undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =item error, warn, info, debug | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | Convenience methods to access the log instance that might | ||||||||||||||||||||
| 35 | be passed during initialisation and set to $self->{log}. | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | =cut | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 40 | 7 | foreach my $i (qw(error warn info debug)) { | |||||||||||||||||||
| 41 | 28 | ▶ | *{$i} = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.4
| |||||||||||||||||||||
| 42 | 317 | my ($self, @args) = @_; | |||||||||||||||||||
| 43 | 317 | ▶ | if ($self->{log}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 317 | return $self->{log}->$i(@args); | |||||||||||||||||||
| 45 | } else { | ||||||||||||||||||||
| 46 | 0 | return; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | 28 | } | |||||||||||||||||||
| 50 | 7 | ▶ | use strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | =item verbose | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | Convenience method to access verbose method of log instance if it exists. | ||||||||||||||||||||
| 55 | When absent, this is an alias for debug. | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =cut | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | sub verbose | ||||||||||||||||||||
| 60 | 145 | ▶ | { | ||||||||||||||||||
|
Subroutine
verbose: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||
| 61 | 145 | my ($self, @args) = @_; | |||||||||||||||||||
| 62 | 145 | ▶ | if ($self->{log}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 145 | ▶ | my $method = $self->{log}->can('verbose') ? 'verbose' : 'debug'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 145 | return $self->{log}->$method(@args); | |||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||
| 66 | 0 | return; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =pod | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =back | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 7 | 1; | |||||||||||||||||||