blib/lib/Pipeline/Store/Simple.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 75.0% 3 / 4 totaltotal 92.1% 47 / 51 CC 4 SCAR 4.5
CC
4
Cov
92%
init
2.1
set
2.0
storehash
2.0
CRAP 1.6
« blib/lib/Pipeline/Segment.pm ↑ Summary lib/Pipeline/Segment/Tester.pm »
1 package Pipeline::Store::Simple;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use Pipeline::Store;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use base qw( Pipeline::Store );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 11 our $VERSION = "3.12";
10  
11 27 ▶sub init {
Subroutine init: called CC=2 SCAR=7.4
Pod documented
12 27 my $self = shift;
13 27 ▶ if ($self->SUPER::init( @_ )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->SUPER::init(@_)) { } 27 0 27
14 27 $self->storehash( {} );
15 27 return 1;
16 } else {
17 0 return 0;
18 }
19 }
20  
21 56 ▶sub storehash {
Subroutine storehash: called CC=2 SCAR=6.9
Pod undocumented
22 56 my $self = shift;
23 56 my $hash = shift;
24 56 ▶ if (defined( $hash )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash) { } 27 29 56
25 27 $self->{ storehash } = $hash;
26 27 return $self;
27 } else {
28 29 return $self->{ storehash };
29 }
30 }
31  
32 13 ▶sub set {
Subroutine set: called CC=2 SCAR=7.0
Pod documented
33 13 my $self = shift;
34 13 my $obj = shift;
35 13 ▶ if (defined( $obj )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $obj) 13 0 13
36 13 $self->storehash->{ ref($obj) } = $obj;
37 }
38 13 return $self;
39 }
40  
41 16 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
42 16 my $self = shift;
43 16 my $key = shift;
44 16 return $self->storehash->{ $key };
45 }
46  
47 11 1;
48  
49  
50 =head1 NAME
51  
52 Pipeline::Store::Simple - simple store for pipelines
53  
54 =head1 SYNOPSIS
55  
56 use Pipeline::Store::Simple;
57  
58 my $store = Pipeline::Store::Simple->new();
59 $store->set( $object );
60 my $object = $store->get( $class );
61  
62 =head1 DESCRIPTION
63  
64 C<Pipeline::Store::Simple> is a simple implementation of a Pipeline store.
65 It stores things as in a hashref indexed by classname. You can add an object
66 to a store by calling the set method with an object, and you can get an object
67 by calling the get method with the classname of the object you wish to retrieve.
68  
69 C<Pipeline::Store::Simple> inherits from the C<Pipeline::Store> class and
70 includes its methods also.
71  
72 =head1 METHODS
73  
74 =over 4
75  
76 =item set( OBJECT )
77  
78 The C<set> method puts OBJECT in the store.
79  
80 =item get( SCALAR )
81  
82 The C<get> method attempts to return an object of the class specified
83 by SCALAR. If an object of that class does not exist in the store it
84 returns undef instead.
85  
86 =back
87  
88 =head1 SEE ALSO
89  
90 C<Pipeline>, C<Pipeline::Store>, C<Pipeline::Store::ISA>
91  
92 =head1 AUTHOR
93  
94 James A. Duncan <jduncan@fotango.com>
95  
96 =head1 COPYRIGHT
97  
98 Copyright 2003 Fotango Ltd. All Rights Reserved.
99  
100 This software is released under the same terms as Perl itself.
101 =cut
102  
103  
104  
« blib/lib/Pipeline/Segment.pm ↑ Summary lib/Pipeline/Segment/Tester.pm »