line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: An Autobox Implementation for Perl 5 |
2
|
|
|
|
|
|
|
package Data::Object::Autobox; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
30552
|
use 5.010; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
75
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
46
|
|
7
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
47
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
6
|
use base 'autobox'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
987
|
|
10
|
2
|
|
|
2
|
|
13848
|
use Data::Object 'load'; |
|
2
|
|
|
|
|
3530
|
|
|
2
|
|
|
|
|
609
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.12'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
2
|
|
|
2
|
|
16
|
my $class = shift; |
16
|
2
|
|
|
|
|
2
|
my $param = shift; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
7
|
my ($default, %options) = ('composite', @_); |
19
|
2
|
100
|
|
|
|
13
|
my ($flavor) = $param =~ /^[-:](autoload|composite|custom)$/ if $param; |
20
|
|
|
|
|
|
|
|
21
|
2
|
100
|
33
|
|
|
12
|
$flavor = $default if ! $flavor |
|
|
|
66
|
|
|
|
|
22
|
|
|
|
|
|
|
or $flavor eq 'custom' and ! keys %options; |
23
|
|
|
|
|
|
|
|
24
|
2
|
100
|
|
|
|
7
|
unless (lc $flavor eq 'custom') { |
25
|
1
|
|
|
|
|
5
|
%options = ( |
26
|
|
|
|
|
|
|
ARRAY => load "${class}::\u${flavor}::Array", |
27
|
|
|
|
|
|
|
CODE => load "${class}::\u${flavor}::Code", |
28
|
|
|
|
|
|
|
FLOAT => load "${class}::\u${flavor}::Float", |
29
|
|
|
|
|
|
|
HASH => load "${class}::\u${flavor}::Hash", |
30
|
|
|
|
|
|
|
INTEGER => load "${class}::\u${flavor}::Integer", |
31
|
|
|
|
|
|
|
NUMBER => load "${class}::\u${flavor}::Number", |
32
|
|
|
|
|
|
|
SCALAR => load "${class}::\u${flavor}::Scalar", |
33
|
|
|
|
|
|
|
STRING => load "${class}::\u${flavor}::String", |
34
|
|
|
|
|
|
|
UNDEF => load "${class}::\u${flavor}::Undef", |
35
|
|
|
|
|
|
|
UNIVERSAL => load "${class}::\u${flavor}::Universal", |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
54
|
$class->SUPER::import(%options); |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
2050
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |