BoardStreams/Context.pm

filter: Statementstmt 61.5% 24 / 39 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 30.0% 3 / 10 Podpod 0.0% 0 / 5 totaltotal 42.8% 27 / 63 CC 10 SCAR 20.6
CC
10
Cov
52%
update
12.0
kick
12.0
disconnect
12.0
CRAP 7.8
« BoardStreams/Client/Membership.pm ↑ Summary BoardStreams/Client.pm »
1 2 ▶use v5.44;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use experimental 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # What join, action and request handlers receive as their first argument.
5 2 class BoardStreams::Context {
6 2 our $VERSION = "v0.0.60";
7  
8 2 ▶ use BoardStreams::Rejection;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 field $hub :param :reader;
11 2 field $c :param :reader; # the WebSocket's Mojolicious controller
12 2 field $channel :param :reader;
13 2 field $connection :param = undef;
14 2 field $user :param :reader = undef; # what the plugin's "identify" option returned for this browser
15 2 field $request_id :param = undef;
16 2 field $seq :reader = 0; # highest sequence number this handler produced
17 2 field $guarded = 0;
18  
19 # Like $hub->update on this handler's channel. The first update made
20 # while handling an action or request is tied to its unique id, so a
21 # resent copy of the same message cannot apply it twice.
22 0 ▶ method update ($cb) {
Subroutine update: not called CC=3 SCAR=24.8
Pod undocumented
23 0 ▶ my @guard = defined $request_id && !$guarded++ ? (request_id => $request_id) : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $request_id && !$guarded++ ? : 0 0 0
Condition0%0/3
defined $request_id and not $guarded++
!ll&&!rl&&r
000
MC/DC0%0/2
defined $request_id and not $guarded++
defined $request_id not $guarded++
Truth table0%0/3
A and not(B)
A= defined $request_idB= not $guarded++
ABresult
0X0
100
111
24 0 ▶ return $hub->update($channel, $cb, @guard)->then(sub ($new_seq) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
25 0 ▶ $seq = $new_seq if $new_seq > $seq;
Branch: 1 branch
BranchTrueFalseTotal
if $new_seq > $seq 0 0 0
26 0 return $new_seq;
27 0 });
28 2 }
29  
30 0 ▶ method emit ($name, $payload = undef) {
Subroutine emit: not called CC=2 SCAR=17.9
Pod undocumented
31 0 ▶ return $self->update(sub ($u) { $u->emit($name, $payload) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 2 }
33  
34 # Ends this browser's membership of the channel, as $hub->kick does
35 # for all of a user's browsers.
36 0 ▶ method kick ($reason = 'kicked', $data = undef) {
Subroutine kick: not called CC=3 SCAR=24.8
Pod undocumented
37 0 return $hub->kick_connection($connection, $channel, $reason, $data);
38 2 }
39  
40 # Closes this browser's connection for good, as $hub->disconnect does
41 # for all of a user's browsers.
42 0 ▶ method disconnect ($reason = 'disconnected', $data = undef) {
Subroutine disconnect: not called CC=3 SCAR=24.8
Pod undocumented
43 0 return $hub->disconnect_connection($connection, $reason, $data);
44 2 }
45  
46 0 ▶ method reject ($reason, $data = undef) {
Subroutine reject: not called CC=2 SCAR=17.9
Pod undocumented
47 0 die BoardStreams::Rejection->new(reason => $reason, data => $data);
48 2 }
49 }
50  
51 2 1;
« BoardStreams/Client/Membership.pm ↑ Summary BoardStreams/Client.pm »