blib/lib/Venus/Role/Superable.pm

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 95.6% 22 / 23 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Venus/Kind/Utility.pm ↑ Summary blib/lib/Venus/Role/Unpackable.pm »
1 package Venus::Role::Superable;
2  
3 1 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # IMPORTS
9  
10 1 ▶use Venus::Role 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # METHODS
13  
14 1 ▶sub super {
Subroutine super: called CC=1 SCAR=0.0
Pod documented
15 1 require mro;
16 1 goto \&next::method
17 }
18  
19 # EXPORTS
20  
21 2 ▶sub EXPORT {
Subroutine EXPORT: called CC=1 SCAR=0.0
Pod undocumented
22 2 ['super']
23 }
24  
25 1 1;
26  
27  
28  
29 =head1 NAME
30  
31 Venus::Role::Superable - Superable Role
32  
33 =cut
34  
35 =head1 ABSTRACT
36  
37 Superable Role for Perl 5
38  
39 =cut
40  
41 =head1 SYNOPSIS
42  
43 package Example;
44  
45 use Venus::Class;
46  
47 with 'Venus::Role::Superable';
48  
49 package main;
50  
51 my $example = Example->new;
52  
53 # $example->super;
54  
55 =cut
56  
57 =head1 DESCRIPTION
58  
59 This package modifies the consuming package and provides methods for
60 dispatching to superclasses using L<mro/next::method>.
61  
62 =cut
63  
64 =head1 METHODS
65  
66 This package provides the following methods:
67  
68 =cut
69  
70 =head2 super
71  
72 super(any @args) (any)
73  
74 The super method dispatches to superclasses uses the C3 method resolution order
75 to get better consistency in multiple inheritance situations.
76  
77 I<Since C<3.55>>
78  
79 =over 4
80  
81 =item super example 1
82  
83 package Example::A;
84  
85 use Venus::Class;
86  
87 sub test {
88 my ($self, @args) = @_;
89  
90 return [$self, @args];
91 }
92  
93 package Example::B;
94  
95 use Venus::Class;
96  
97 base 'Example::A';
98  
99 with 'Venus::Role::Superable';
100  
101 sub test {
102 my ($self) = @_;
103  
104 return $self->super(1..4);
105 }
106  
107 package main;
108  
109 my $example = Example::B->new;
110  
111 my $result = $example->test;
112  
113 =back
114  
115 =cut
116  
117 =head1 AUTHORS
118  
119 Awncorp, C<awncorp@cpan.org>
120  
121 =cut
122  
123 =head1 LICENSE
124  
125 Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>.
126  
127 This program is free software, you can redistribute it and/or modify it under
128 the terms of the Apache license version 2.0.
129  
130 =cut
« blib/lib/Venus/Kind/Utility.pm ↑ Summary blib/lib/Venus/Role/Unpackable.pm »