DS/Target/Sth.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 28 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
receive_row
2.0
BEGIN
2.0
CRAP 2.0
1 #!perl
2
3 # ########################################################################## #
4 # Title: Data stream sink
5 # Creation date: 2007-04-16
6 # Author: Michael Zedeler
7 # Description: Receives data, binds to statement handle parameters and
8 # executes statement handle for each row.
9 # Data Stream class
10 # File: $Source: /data/cvs/lib/DSlib/lib/DS/Target/Sth.pm,v $
11 # Repository: kronhjorten
12 # State: $State: Exp $
13 # Documentation: inline
14 # Recepient: -
15 # ########################################################################## #
16
17 package DS::Target::Sth;
18
19 use base qw{ DS::Target };
20
21 use strict;
22
23 our ($VERSION) = $DS::VERSION;
24 our ($REVISION) = '$Revision: 1.1 $' =~ /(\d+\.\d+)/;
25 our ($STATE) = '$State: Exp $' =~ /:\s+(.+\S)\s+\$$/;
26
27 sub new {
28 my( $class, $in_type, $source, $sth, $bind_map ) = @_;
29
30 my $self = $class->SUPER::new( $in_type, $source );
31
32 #TODO Make sure that $bind_map and $in_type corresponds
33
34 should( ref( $sth ) => 'DBI::st' );
35 should( ref( $bind_map ) => 'HASH' );
36
37 $self->{sth} = $bind_map;
38 $self->{bind_map} = $bind_map;
39
40 return $self;
41 }
42
43 sub receive_row {
44 my( $self, $row ) = @_;
45
46 foreach my $parnum ( keys %{$self->{bind_map}} ) {
47 my $field = $self->{bind_map}->{$parnum};
48 $self->{sth}->bind_param( $parnum, $row->{ $field } );
49 }
50
51 $self->{sth}->execute();
52 }
53
54 1;