Minor fix to the previous doc patch
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / CDBICompat / Relationship.pm
CommitLineData
a9c8094b 1package
2 DBIx::Class::CDBICompat::Relationship;
3
4use strict;
5use warnings;
ddc0a6c8 6use Sub::Name ();
a9c8094b 7
8=head1 NAME
9
b24d86a1 10DBIx::Class::CDBICompat::Relationship - Emulate the Class::DBI::Relationship object returned from meta_info()
a9c8094b 11
12=head1 DESCRIPTION
13
14Emulate the Class::DBI::Relationship object returned from C<meta_info()>.
15
16=cut
17
18my %method2key = (
19 name => 'type',
20 class => 'self_class',
21 accessor => 'accessor',
22 foreign_class => 'class',
1097f5e4 23 args => 'args',
a9c8094b 24);
25
26sub new {
27 my($class, $args) = @_;
d4daee7b 28
a9c8094b 29 return bless $args, $class;
30}
31
32for my $method (keys %method2key) {
33 my $key = $method2key{$method};
34 my $code = sub {
35 $_[0]->{$key};
36 };
d4daee7b 37
a9c8094b 38 no strict 'refs';
ddc0a6c8 39 *{$method} = Sub::Name::subname $method, $code;
a9c8094b 40}
41
a9c8094b 421;