1 package # hide from PAUSE Indexer
2 DBIx::Class::CDBICompat::AccessorMapping;
7 sub mk_group_accessors {
8 my ($class, $group, @cols) = @_;
9 unless ($class->can('accessor_name') || $class->can('mutator_name')) {
10 return $class->next::method($group => @cols);
12 foreach my $col (@cols) {
13 my $ro_meth = ($class->can('accessor_name')
14 ? $class->accessor_name($col)
16 my $wo_meth = ($class->can('mutator_name')
17 ? $class->mutator_name($col)
19 #warn "$col $ro_meth $wo_meth";
20 if ($ro_meth eq $wo_meth) {
21 $class->next::method($group => [ $ro_meth => $col ]);
23 $class->mk_group_ro_accessors($group => [ $ro_meth => $col ]);
24 $class->mk_group_wo_accessors($group => [ $wo_meth => $col ]);
30 my ($class, $attrs, @rest) = @_;
31 $class->throw_exception( "create needs a hashref" ) unless ref $attrs eq 'HASH';
32 foreach my $col ($class->columns) {
33 if ($class->can('accessor_name')) {
34 my $acc = $class->accessor_name($col);
35 $attrs->{$col} = delete $attrs->{$acc} if exists $attrs->{$acc};
37 if ($class->can('mutator_name')) {
38 my $mut = $class->mutator_name($col);
39 $attrs->{$col} = delete $attrs->{$mut} if exists $attrs->{$mut};
42 return $class->next::method($attrs, @rest);