line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE Indexer |
2
|
|
|
|
|
|
|
DBIx::Class::CDBICompat::AccessorMapping; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
841
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
66
|
|
5
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
64
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
13
|
use base 'DBIx::Class'; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
214
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
16
|
use Scalar::Util 'blessed'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
101
|
|
10
|
2
|
|
|
2
|
|
12
|
use namespace::clean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub mk_group_accessors { |
13
|
0
|
|
|
0
|
1
|
|
my ($class, $group, @cols) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
foreach my $col (@cols) { |
16
|
0
|
0
|
|
|
|
|
my($accessor, $col) = ref $col eq 'ARRAY' ? @$col : (undef, $col); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my($ro_meth, $wo_meth); |
19
|
0
|
0
|
0
|
|
|
|
if (defined blessed $col and $col->isa('Class::DBI::Column')) { |
|
|
0
|
0
|
|
|
|
|
20
|
0
|
|
|
|
|
|
$ro_meth = $col->accessor; |
21
|
0
|
|
|
|
|
|
$wo_meth = $col->mutator; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
elsif (defined $accessor and ($accessor ne $col)) { |
24
|
0
|
|
|
|
|
|
$ro_meth = $wo_meth = $accessor; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
0
|
|
|
|
|
|
$ro_meth = $class->accessor_name_for($col); |
28
|
0
|
|
|
|
|
|
$wo_meth = $class->mutator_name_for($col); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# warn "class: $class / col: $col / ro: $ro_meth / wo: $wo_meth\n"; |
32
|
0
|
0
|
0
|
|
|
|
if ($ro_meth eq $wo_meth or # they're the same |
33
|
|
|
|
|
|
|
$wo_meth eq $col) # or only the accessor is custom |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
|
|
|
$class->next::method($group => [ $ro_meth => $col ]); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
0
|
|
|
|
|
|
$class->mk_group_ro_accessors($group => [ $ro_meth => $col ]); |
39
|
0
|
|
|
|
|
|
$class->mk_group_wo_accessors($group => [ $wo_meth => $col ]); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub accessor_name_for { |
46
|
0
|
|
|
0
|
0
|
|
my ($class, $column) = @_; |
47
|
0
|
0
|
|
|
|
|
if ($class->can('accessor_name')) { |
48
|
0
|
|
|
|
|
|
return $class->accessor_name($column) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $column; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub mutator_name_for { |
55
|
0
|
|
|
0
|
0
|
|
my ($class, $column) = @_; |
56
|
0
|
0
|
|
|
|
|
if ($class->can('mutator_name')) { |
57
|
0
|
|
|
|
|
|
return $class->mutator_name($column) |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $column; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub new { |
65
|
0
|
|
|
0
|
0
|
|
my ($class, $attrs, @rest) = @_; |
66
|
0
|
0
|
|
|
|
|
$class->throw_exception( "create needs a hashref" ) unless ref $attrs eq 'HASH'; |
67
|
0
|
|
|
|
|
|
foreach my $col ($class->columns) { |
68
|
0
|
|
|
|
|
|
my $acc = $class->accessor_name_for($col); |
69
|
0
|
0
|
|
|
|
|
$attrs->{$col} = delete $attrs->{$acc} if exists $attrs->{$acc}; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $mut = $class->mutator_name_for($col); |
72
|
0
|
0
|
|
|
|
|
$attrs->{$col} = delete $attrs->{$mut} if exists $attrs->{$mut}; |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
return $class->next::method($attrs, @rest); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |