Peer/Listener.pm

filter: Statementstmt 100% 23 / 23 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 96.9% 32 / 33 CC 2 SCAR 2.5
CC
2
Cov
96%
BUILD
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Peer/Event.pm ↑ Summary Peer/UnsubscribeEvent.pm »
1 # ABSTRACT: Net::Object::Peer specfic Listener
2 package Net::Object::Peer::Listener;
3  
4 20 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 20 ▶use Types::Standard qw[ ConsumerOf InstanceOf ];
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 ▶use Net::Object::Peer::RefAddr;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 20 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 20 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 20 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 20 extends 'BeamX::Peer::Listener';
13  
14 20 our $VERSION = '0.06'; # TRIAL
15  
16 20 has +peer => (
17 is => 'ro',
18 isa => ConsumerOf ['Net::Object::Peer'],
19 weak_ref => 1,
20 );
21  
22 #pod =attr addr
23 #pod
24 #pod The reference address of the true emitter
25 #pod
26 #pod =cut
27  
28 20 has addr => (
29 is => 'rwp',
30 isa => InstanceOf['Net::Object::Peer::RefAddr'],
31 predicate => 1,
32 );
33  
34  
35 #pod =begin pod_coverage
36 #pod
37 #pod =head4 BUILD
38 #pod
39 #pod =head4 has_addr
40 #pod
41 #pod =end pod_coverage
42 #pod
43 #pod =cut
44  
45 58 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.6
Pod documented
46  
47 # do this as soon as possible. if it's lazy, peer may disappear
48 # before a lazy builder can run
49 58 ▶ $_[0]->_set_addr( Net::Object::Peer::RefAddr->new( $_[0]->peer ) )
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->has_addr 58 0 58
50 unless $_[0]->has_addr;
51 }
52  
53 20 1;
54  
55 #
56 # This file is part of Net-Object-Peer
57 #
58 # This software is Copyright (c) 2016 by Smithsonian Astrophysical Observatory.
59 #
60 # This is free software, licensed under:
61 #
62 # The GNU General Public License, Version 3, June 2007
63 #
64  
65 =pod
66  
67 =head1 NAME
68  
69 Net::Object::Peer::Listener - Net::Object::Peer specfic Listener
70  
71 =head1 VERSION
72  
73 version 0.06
74  
75 =head1 DESCRIPTION
76  
77 B<Net::Object::Peer::Listener> is a sub-class of L<BeamX::Peer::Listener>,
78 which
79  
80 =over
81  
82 =item *
83  
84 adds the requirement that the peer be a consumer of L<Net::Object::Peer>.
85  
86 =item *
87  
88 adds an C<addr> attribute, which contains the refaddr of C<peer>.
89  
90 =back
91  
92 Listener classes used with L<Net::Object::Peer> must be derived from
93 this class.
94  
95 =head1 ATTRIBUTES
96  
97 =head2 addr
98  
99 The reference address of the true emitter
100  
101 =begin pod_coverage
102  
103 =head4 BUILD
104  
105 =head4 has_addr
106  
107 =end pod_coverage
108  
109 =head1 AUTHOR
110  
111 Diab Jerius <djerius@cpan.org>
112  
113 =head1 COPYRIGHT AND LICENSE
114  
115 This software is Copyright (c) 2016 by Smithsonian Astrophysical Observatory.
116  
117 This is free software, licensed under:
118  
119 The GNU General Public License, Version 3, June 2007
120  
121 =cut
122  
123 __END__
« Peer/Event.pm ↑ Summary Peer/UnsubscribeEvent.pm »