blib/lib/Pipeline/Segment.pm

filter: Statementstmt 97.8% 46 / 47 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 85.7% 6 / 7 totaltotal 96.0% 72 / 75 CC 5 SCAR 4.7
CC
5
Cov
96%
parent
3.0
init
2.1
store
2.0
CRAP 1.6
« blib/lib/Pipeline/Segment/Async/Fork.pm ↑ Summary blib/lib/Pipeline/Store/Simple.pm »
1 package Pipeline::Segment;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 ▶use Pipeline::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use Scalar::Util qw( weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Pipeline::Error::Abstract;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 13 ▶use base qw( Pipeline::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 13 our $VERSION = "3.12";
13  
14 46 ▶sub init {
Subroutine init: called CC=2 SCAR=7.4
Pod documented
15 46 my $self = shift;
16 46 ▶ if ($self->SUPER::init()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->SUPER::init) { } 46 0 46
17 46 $self->parent( '' );
18 46 return 1;
19 } else {
20 0 return undef;
21 }
22 }
23  
24 1 ▶sub dispatch {
Subroutine dispatch: called CC=1 SCAR=0.0
Pod documented
25 1 throw Pipeline::Error::Abstract;
26 }
27  
28 22 ▶sub dispatch_method { undef }
Subroutine dispatch_method: called CC=1 SCAR=0.0
Pod documented
29  
30 23 ▶sub prepare_dispatch {
Subroutine prepare_dispatch: called CC=1 SCAR=0.0
Pod undocumented
31 23 my $self = shift;
32 23 my $pipe = shift;
33 23 $self->parent( $pipe );
34 23 $self->store( $pipe->store );
35 }
36  
37 23 ▶sub cleanup_dispatch {
Subroutine cleanup_dispatch: called CC=1 SCAR=0.0
Pod documented
38 23 my $self = shift;
39 23 $self->{ parent } = undef;
40 23 $self->{ store } = undef;
41 }
42  
43 141 ▶sub parent {
Subroutine parent: called CC=3 SCAR=11.0
Pod documented
44 141 my $self = shift;
45 141 my $seg = shift;
46 141 ▶ if (defined( $seg )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seg) { } 71 70 141
47 71 $self->{ parent } = $seg;
48 71 ▶ weaken( $self->{ parent } ) if ref( $seg );
Branch: 1 branch
BranchTrueFalseTotal
if ref $seg 25 46 71
49 71 return $self;
50 } else {
51 70 return $self->{ parent };
52 }
53 }
54  
55 150 ▶sub store {
Subroutine store: called CC=2 SCAR=6.9
Pod documented
56 150 my $self = shift;
57 150 my $store = shift;
58 150 ▶ if (defined( $store )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $store) { } 51 99 150
59 51 $self->{ store } = $store;
60 51 return $self;
61 } else {
62 99 return $self->{ store };
63 }
64 }
65  
66 13 1;
67  
68 =head1 NAME
69  
70 Pipeline::Segment - basic class for a segment
71  
72 =head1 SYNOPSIS
73  
74 use Pipeline::Segment;
75 my $ps = Pipeline::Segment->new();
76 $ps->dispatch();
77  
78 =head1 DESCRIPTION
79  
80 C<Pipeline::Segment> is designed as a part of the C<Pipeline> system. The
81 C<Pipeline::Segment> class is designed to be subclassed as a part of the Pipeline
82 system. The primary method that needs to be overloaded is the C<dispatch> method,
83 which the Pipeline class uses to enter each individual segment that it contains.
84  
85 =head1 METHODS
86  
87 The C<Pipeline::Segment> class inherits from C<Pipeline::Base> and therefore
88 also has any additional methods that its superclass may have.
89  
90 =over 4
91  
92 =item init()
93  
94 The C<init> method is called at construction time. Any arguments passed to the
95 C<new> method are passed to it.
96  
97 =item dispatch()
98  
99 The C<dispatch> method causes the segment to perform its action.
100  
101 =item dispatch_method()
102  
103 The C<dispatch_method> gets and sets the method that gets called on dispatch, by
104 default this is the C<dispatch()> method.
105  
106 =item cleanup_dispatch()
107  
108 The C<cleanup_dispatch> method does post-processing on the segment to ensure
109 no nasty circular references are lying around, as well as disconnecting
110 various objects that are only useful during a dispatch.
111  
112 =item store()
113  
114 The C<store> method gets the current store.
115  
116 =item parent()
117  
118 The C<parent> method returns the pipeline that the segment is current operating from.
119 It is set at dispatch time by the calling pipeline.
120  
121 =back
122  
123 =head1 SEE ALSO
124  
125 C<Pipeline>, C<Pipeline::Segment::Async>
126  
127 =head1 AUTHOR
128  
129 James A. Duncan <jduncan@fotango.com>
130  
131 =head1 COPYRIGHT
132  
133 Copyright 2003 Fotango Ltd. All Rights Reserved.
134  
135 This software is released under the same terms as Perl itself.
136 =cut
137  
138  
« blib/lib/Pipeline/Segment/Async/Fork.pm ↑ Summary blib/lib/Pipeline/Store/Simple.pm »