blib/lib/Pipeline/Store.pm

filter: Statementstmt 91.4% 32 / 35 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 83.3% 10 / 12 Podpod 85.7% 6 / 7 totaltotal 84.2% 59 / 70 CC 6 SCAR 7.3
CC
6
Cov
87%
init
3.8
end_transaction
3.0
new
2.0
CRAP 2.1
« blib/lib/Pipeline/Segment/Async/IThreads.pm ↑ Summary blib/lib/Pipeline/Dispatch.pm »
1 package Pipeline::Store;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use Pipeline::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use base qw( Pipeline::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 our $VERSION = "3.12";
10  
11 34 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
12 34 my $class = shift;
13 34 ▶ if ( $class->in_transaction() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->in_transaction) { } 5 29 34
14 5 return $::TRANSACTION_STORE;
15 } else {
16 29 my $store = $class->SUPER::new( @_ );
17 }
18 }
19  
20 23 ▶sub start_transaction {
Subroutine start_transaction: called CC=1 SCAR=0.0
Pod documented
21 23 my $self = shift;
22 23 $::TRANSACTION = 1;
23 23 $::TRANSACTION_STORE = $self;
24 }
25  
26 78 ▶sub in_transaction {
Subroutine in_transaction: called CC=1 SCAR=0.0
Pod undocumented
27 78 my $self = shift;
28 78 $::TRANSACTION;
29 }
30  
31 44 ▶sub end_transaction {
Subroutine end_transaction: called CC=3 SCAR=11.0
Pod documented
32 44 my $self = shift;
33 44 ▶ if ($self->in_transaction && $self == $::TRANSACTION_STORE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->in_transaction and $self == $main::TRANSACTION_STORE) { } 19 25 44
Condition100%3/3
$self->in_transaction and $self == $main::TRANSACTION_STORE
!ll&&!rl&&r
24119
MC/DC100%2/2
$self->in_transaction and $self == $main::TRANSACTION_STORE
$self->in_transaction $self == $main::TRANSACTION_STORE
Truth table100%3/3
A and B
A= $self->in_transactionB= $self == $main::TRANSACTION_STORE
ABresult
0X0
100
111
34 19 $::TRANSACTION = 0;
35 } else {
36 25 $self->emit("cannot clear transaction unless it is called by the same object");
37 }
38 }
39  
40 29 ▶sub init {
Subroutine init: called CC=3 SCAR=13.3
Pod documented
41 29 my $self = shift;
42 29 ▶ if ($self->SUPER::init( @_ ) && ref($self) ne 'Pipeline::Store') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->SUPER::init(@_) and ref $self ne 'Pipeline::Store') { } 29 0 29
Condition33%1/3
$self->SUPER::init(@_) and ref $self ne "Pipeline::Store"
!ll&&!rl&&r
0029
MC/DC0%0/2
$self->SUPER::init(@_) and ref $self ne "Pipeline::Store"
$self->SUPER::init(@_) ref $self ne "Pipeline::Store"
Truth table33%1/3
A and B
A= $self->SUPER::init(@_)B= ref $self ne "Pipeline::Store"
ABresult
0X0
100
111
43 29 return 1;
44 } else {
45 0 return 0;
46 }
47 }
48  
49 0 ▶sub set {
Subroutine set: not called CC=1 SCAR=6.9
Pod documented
50 0 throw Pipeline::Error::Abstract;
51 }
52  
53 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod documented
54 0 throw Pipeline::Error::Abstract;
55 }
56  
57 21 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
58 21 my $self = shift;
59 21 $self->end_transaction;
60 }
61  
62 12 1;
63  
64  
65 =head1 NAME
66  
67 Pipeline::Store - defines the interface for Pipeline store classes
68  
69 =head1 SYNOPSIS
70  
71 use Pipeline::Store; # interface class, does very little
72  
73 =head1 DESCRIPTION
74  
75 C<Pipeline::Store> provides a constructor and a generic get/set interface
76 for any class implementing a store to sit on a Pipeline. Pipeline stores
77 are singletons inside the dispatch process. Ie, if you attempt to construct
78 a pipeline store in between the dispatch method being called on a pipeline
79 segment and having the method return a value then you will get the same
80 store as that segments store() method.
81  
82 =head1 METHODS
83  
84 The Pipeline class inherits from the C<Pipeline::Base> class and therefore
85 also has any additional methods that its superclass may have.
86  
87 =over 4
88  
89 =item new()
90  
91 The C<new> method constructs a new Pipeline::Store object and calls
92 the C<init> method. If the transaction flat is set then it returns
93 the current store singleton.
94  
95 =item init()
96  
97 The C<init> method is called by new() to do any construction-time initialization
98 of an object.
99  
100 =item start_transaction
101  
102 Sets the transaction flag, which makes the store object that this is called on a
103 singleton until end_transaction is called.
104  
105 =item end_transaction
106  
107 Clears the transaction flag, which lets you construct new pipeline stores.
108  
109 =item store( [ store ] )
110  
111 The C<store> method gets or sets the store in a Pipeline::Store object. Unless C<init>
112 is changed the store is set at construction time to a hash reference.
113  
114 =item get()
115  
116 Does nothing in Pipeline::Store - exists as a placeholder for subclasses.
117  
118 =item set()
119  
120 Does nothing in Pipeline::Store - exists as a placeholder for subclasses.
121  
122 =back
123  
124 =head1 SEE ALSO
125  
126 C<Pipeline>, C<Pipeline::Store::Simple>, C<Pipeline::Store::ISA>
127  
128 =head1 COPYRIGHT
129  
130 Copyright 2003 Fotango Ltd. All Rights Reserved
131  
132 This module is released under the same license as Perl itself.
133  
134 =head1 AUTHOR
135  
136 James A. Duncan <jduncan@fotango.com>
137  
138 =cut
« blib/lib/Pipeline/Segment/Async/IThreads.pm ↑ Summary blib/lib/Pipeline/Dispatch.pm »