| 1 | package Net::HTTP::API::Meta::Method::APIDeclare; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | $Net::HTTP::API::Meta::Method::APIDeclare::VERSION = '0.14'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # ABSTRACT: declare API | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Net::HTTP::API::Error; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | my @accepted_options = qw/ | |||||||||||||||||||||||||||
| 12 | api_base_url | ||||||||||||||||||||||||||||
| 13 | api_format | ||||||||||||||||||||||||||||
| 14 | api_format_mode | ||||||||||||||||||||||||||||
| 15 | api_username | ||||||||||||||||||||||||||||
| 16 | api_password | ||||||||||||||||||||||||||||
| 17 | authentication | ||||||||||||||||||||||||||||
| 18 | authentication_method | ||||||||||||||||||||||||||||
| 19 | /; | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | has api_options => ( | ||||||||||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||||||||||
| 23 | traits => ['Hash'], | ||||||||||||||||||||||||||||
| 24 | isa => 'HashRef[Str|CodeRef]', | ||||||||||||||||||||||||||||
| 25 | 4 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 4 | lazy => 1, | |||||||||||||||||||||||||||
| 27 | handles => { | ||||||||||||||||||||||||||||
| 28 | set_api_option => 'set', | ||||||||||||||||||||||||||||
| 29 | get_api_option => 'get', | ||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 3 | ▶ | sub add_net_api_declare { | ||||||||||||||||||||||||||
|
Subroutine
add_net_api_declare: called CC=8 SCAR=22.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 3 | my ($meta, $name, %options) = @_; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 3 | ▶ | if ($options{useragent}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | die Net::HTTP::API::Error->new( | ||||||||||||||||||||||||||||
| 38 | reason => "'useragent' must be a CODE ref") | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | unless ref $options{useragent} eq 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | $meta->set_api_option(useragent => delete $options{useragent}); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # XXX for backward compatibility | ||||||||||||||||||||||||||||
| 44 | 3 | for my $attr (qw/base_url format format_mode username password/) { | |||||||||||||||||||||||||||
| 45 | 15 | my $attr_name = "api_" . $attr; | |||||||||||||||||||||||||||
| 46 | 15 | ▶ | if (exists $options{$attr} && !exists $options{$attr_name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $options{$attr} and not exists $options{$attr_name}
MC/DC50%1/2
exists $options{$attr} and not exists $options{$attr_name}
exists $options{$attr}
not exists $options{$attr_name}
Truth table66%2/3
A and not(B)
A= exists $options{$attr}B= not exists $options{$attr_name}
| |||||||||||||||||||||||||||||
| 47 | 3 | $options{$attr_name} = delete $options{$attr}; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 3 | for my $attr (@accepted_options) { | |||||||||||||||||||||||||||
| 52 | 21 | ▶ | $meta->set_api_option($attr => $options{$attr}) if defined $options{$attr}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 4 | 1; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||