Zing/Zang.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 43 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Zing::Zang;
2  
3 use 5.014;
4  
5 use strict;
6 use warnings;
7  
8 use registry;
9 use routines;
10  
11 use Data::Object::Class;
12 use Data::Object::ClassHas;
13  
14 extends 'Zing::Process';
15  
16 our $VERSION = '0.11'; # VERSION
17  
18 # ATTRIBUTES
19  
20 has 'on_perform' => (
21 is => 'ro',
22 isa => 'Maybe[CodeRef]',
23 opt => 1,
24 );
25  
26 has 'on_receive' => (
27 is => 'ro',
28 isa => 'Maybe[CodeRef]',
29 opt => 1,
30 );
31  
32 # METHODS
33  
34 method receive(@args) {
35 return $self if !$self->on_receive;
36  
37 $self->on_receive->($self, @args);
38  
39 return $self;
40 }
41  
42 method perform(@args) {
43 return $self if !$self->on_perform;
44  
45 $self->on_perform->($self, @args);
46  
47 return $self;
48 }
49  
50 1;
51  
52 =encoding utf8
53  
54 =head1 NAME
55  
56 Zing::Zang - Process Implementation
57  
58 =cut
59  
60 =head1 ABSTRACT
61  
62 Process Implementation
63  
64 =cut
65  
66 =head1 SYNOPSIS
67  
68 use Zing::Zang;
69  
70 my $zang = Zing::Zang->new(
71 on_perform => sub {
72 my ($self) = @_;
73  
74 $self->{performed}++
75 }
76 );
77  
78 # $zang->execute;
79  
80 =cut
81  
82 =head1 DESCRIPTION
83  
84 This package provides a standard L<Zing::Process> which uses callbacks and
85 doesn't need to be subclassed. It supports providing the standard process
86 C<perform> method as C<on_perform> and C<receive> method as C<on_receive> which
87 operate as expected.
88  
89 =cut
90  
91 =head1 INHERITS
92  
93 This package inherits behaviors from:
94  
95 L<Zing::Process>
96  
97 =cut
98  
99 =head1 LIBRARIES
100  
101 This package uses type constraints from:
102  
103 L<Zing::Types>
104  
105 =cut
106  
107 =head1 ATTRIBUTES
108  
109 This package has the following attributes:
110  
111 =cut
112  
113 =head2 on_perform
114  
115 on_perform(Maybe[CodeRef])
116  
117 This attribute is read-only, accepts C<(Maybe[CodeRef])> values, and is optional.
118  
119 =cut
120  
121 =head2 on_receive
122  
123 on_receive(Maybe[CodeRef])
124  
125 This attribute is read-only, accepts C<(Maybe[CodeRef])> values, and is optional.
126  
127 =cut
128  
129 =head1 AUTHOR
130  
131 Al Newkirk, C<awncorp@cpan.org>
132  
133 =head1 LICENSE
134  
135 Copyright (C) 2011-2019, Al Newkirk, et al.
136  
137 This is free software; you can redistribute it and/or modify it under the terms
138 of the The Apache License, Version 2.0, as elucidated in the L<"license
139 file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>.
140  
141 =head1 PROJECT
142  
143 L<Wiki|https://github.com/iamalnewkirk/zing/wiki>
144  
145 L<Project|https://github.com/iamalnewkirk/zing>
146  
147 L<Initiatives|https://github.com/iamalnewkirk/zing/projects>
148  
149 L<Milestones|https://github.com/iamalnewkirk/zing/milestones>
150  
151 L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md>
152  
153 L<Issues|https://github.com/iamalnewkirk/zing/issues>
154  
155 =cut