File Coverage

blib/lib/Win32/SqlServer/DTS/AssignmentFactory.pm
Criterion Covered Total %
statement 12 19 63.1
branch 0 2 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 27 62.9


line stmt bran cond sub pod time code
1             package Win32::SqlServer::DTS::AssignmentFactory;
2            
3             =head1 NAME
4            
5             Win32::SqlServer::DTS::AssigmentFactory - a Perl abstract class to create DynamicPropertiesTaskAssignment objects
6            
7             =head1 SYNOPSIS
8            
9             use Win32::SqlServer::DTS::Task::DynamicProperty;
10             use Win32::SqlServer::DTS::AssignmentFactory;
11            
12             my $assignments = $dyn_props->get_sibling->Assignments;
13             my @assigments;
14            
15             if ( defined($assignments) ) {
16            
17             foreach my $assignment ( in($assignments) ) {
18            
19             push( @assignments,
20             Win32::SqlServer::DTS::AssignmentFactory->create($assignment) );
21            
22             }
23            
24             return \@assignments;
25            
26             } else {
27            
28             warn "This dynamic properties does not have any assignment\r\n";
29            
30             }
31            
32             =head1 DESCRIPTION
33            
34             C is a simple abstract actory to create L objects.
35             This abstract class should be used only if one wants to extend the C API.
36            
37             =head2 EXPORT
38            
39             None by default.
40            
41             =cut
42            
43 1     1   14120 use strict;
  1         1  
  1         28  
44 1     1   3 use warnings;
  1         1  
  1         18  
45 1     1   3 use Carp;
  1         1  
  1         55  
46 1     1   296 use Win32::SqlServer::DTS::AssignmentTypes;
  1         2  
  1         82  
47            
48             =head2 METHODS
49            
50             =head3 create
51            
52             Expects an DTS Assignment object as a parameter. Returns an L object in a
53             polymorphic way, depending on the DTS Assignment type.
54            
55             =cut
56            
57             sub create {
58            
59 0     0 1   my $assignment = $_[1];
60            
61 0 0         confess "Must received a valid assignment as a parameter\n"
62             unless ( defined($assignment) );
63            
64 0           my $type = Win32::SqlServer::DTS::AssignmentTypes->get_class_name( $assignment->SourceType );
65            
66             # using DOS directory separator
67 0           my $location = 'Win32\\SqlServer\\DTS\\Assignment\\' . $type . '.pm';
68 0           my $new_class = 'Win32::SqlServer::DTS::Assignment::' . $type;
69            
70 0           require $location;
71            
72 0           return $new_class->new($assignment);
73            
74             }
75            
76             1;
77            
78             __END__