Peer/Event.pm

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