IDL/Method.pm

filter: Statementstmt 79.3% 23 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 80.0% 4 / 5 totaltotal 79.0% 34 / 43 CC 2 SCAR 3.4
CC
2
Cov
79%
fields
2.0
setup
2.0
to_str
2.0
CRAP 1.4
« IDL/Type/Set.pm ↑ Summary Parser/Type/void.pm »
1 package Thrift::IDL::Method;
2  
3 =head1 NAME
4  
5 Thrift::IDL::Method
6  
7 =head1 DESCRIPTION
8  
9 Inherits from L<Thrift::IDL::Base>
10  
11 =cut
12  
13 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use base qw(Thrift::IDL::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 __PACKAGE__->mk_accessors(qw(name oneway returns arguments throws service));
17 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 =head1 METHODS
20  
21 =head2 name
22  
23 =head2 oneway
24  
25 =head2 returns
26  
27 =head2 arguments
28  
29 =head2 throws
30  
31 =head2 service
32  
33 Scalar accessors
34  
35 =head2 fields
36  
37 Alias to C<arguments>
38  
39 =head2 field_named ($name)
40  
41 =head2 argument_named ($name)
42  
43 =head2 field_id ($id)
44  
45 =head2 argument_id ($id)
46  
47 Returns object found in named array with given key value
48  
49 =cut
50  
51 # Having similarly named functions as Structs allows us to be processed similarly
52  
53 0 ▶sub fields {
Subroutine fields: not called CC=1 SCAR=6.9
Pod documented
54 0 my $self = shift;
55 0 $self->arguments(@_);
56 }
57  
58 3 ▶sub field_named {
Subroutine field_named: called CC=1 SCAR=0.0
Pod documented
59 3 my ($self, $name) = @_;
60 3 $self->array_search($name, 'arguments', 'name');
61 }
62 4 *argument_named = \&field_named;
63  
64 2 ▶sub field_id {
Subroutine field_id: called CC=1 SCAR=0.0
Pod documented
65 2 my ($self, $name) = @_;
66 2 $self->array_search($name, 'arguments', 'id');
67 }
68 4 *argument_id = \&field_id;
69  
70 =head2 setup
71  
72 A method C<arguments> and C<throws> has children of type L<Thrift::IDL::Field> and L<Thrift::IDL::Comment>. Walk through all these children and associate the comments with the fields that preceeded them (if perl style) or with the field following.
73  
74 =cut
75
76 7 ▶sub setup {
Subroutine setup: called CC=2 SCAR=6.9
Pod documented
77 7 my $self = shift;
78 7 foreach my $children_key (qw(arguments throws)) {
79 14 $self->_setup($children_key);
80 }
81 }
82  
83 0 ▶sub to_str {
Subroutine to_str: not called CC=1 SCAR=6.9
Pod undocumented
84 0 my ($self) = @_;
85  
86 return sprintf '%s (%s)',
87 $self->name,
88 join(', ',
89 0 map { $_ .': '. $self->$_ }
90 0 grep { defined $self->$_ }
91 qw(returns oneway)
92 );
93 }
94  
95 4 1;
« IDL/Type/Set.pm ↑ Summary Parser/Type/void.pm »