line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
25781
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Class::Factory::Enhanced; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
19
|
$Class::Factory::Enhanced::VERSION = '1.101420'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: More functionality for Class::Factory |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use parent 'Class::Factory'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# add support for defining several mappings at once |
14
|
|
|
|
|
|
|
sub add_factory_type { |
15
|
2
|
|
|
2
|
1
|
26
|
my ($item, @args) = @_; |
16
|
2
|
|
33
|
|
|
14
|
my $class = ref $item || $item; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# SUPER::add_factory_type, which only allows one mapping, returns the |
19
|
|
|
|
|
|
|
# object class. The return value is not used when defining the mappings, |
20
|
|
|
|
|
|
|
# but it is used in get_factory_class(). get_factory_class() only calls |
21
|
|
|
|
|
|
|
# this with one argument, so return the first object class we see. It's a |
22
|
|
|
|
|
|
|
# hack, yes... |
23
|
2
|
|
|
|
|
1
|
my $first_object_class; |
24
|
2
|
|
|
|
|
9
|
while (my ($object_type, $object_class) = splice @args, 0, 2) { |
25
|
2
|
|
|
|
|
13
|
$class->SUPER::remove_factory_type($object_type); |
26
|
2
|
|
|
|
|
24
|
$class->SUPER::add_factory_type($object_type, $object_class); |
27
|
2
|
|
33
|
|
|
2449
|
$first_object_class ||= $object_class; |
28
|
|
|
|
|
|
|
} |
29
|
2
|
|
|
|
|
6
|
return $first_object_class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub register_factory_type { |
33
|
2
|
|
|
2
|
1
|
1269
|
my ($item, @args) = @_; |
34
|
2
|
|
33
|
|
|
14
|
my $class = ref $item || $item; |
35
|
2
|
|
|
|
|
8
|
while (my ($object_type, $object_class) = splice @args, 0, 2) { |
36
|
4
|
|
|
|
|
37
|
$class->SUPER::unregister_factory_type($object_type); |
37
|
4
|
|
|
|
|
48
|
$class->SUPER::register_factory_type($object_type, $object_class); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub make_object_for_type { |
42
|
2
|
|
|
2
|
1
|
34
|
my ($self, $object_type, @args) = @_; |
43
|
2
|
|
|
|
|
12
|
my $class = $self->get_factory_class($object_type); |
44
|
2
|
|
|
|
|
18
|
$class->new(@args); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |