Commit | Line | Data |
a9c8094b |
1 | package |
2 | DBIx::Class::CDBICompat::Relationship; |
3 | |
4 | use strict; |
5 | use warnings; |
6 | |
7 | |
8 | =head1 NAME |
9 | |
10 | DBIx::Class::CDBICompat::Relationship |
11 | |
12 | =head1 DESCRIPTION |
13 | |
14 | Emulate the Class::DBI::Relationship object returned from C<meta_info()>. |
15 | |
aa11d765 |
16 | The C<args()> method does not return any useful result as it's not clear what it should contain nor if any of the information is applicable to DBIx::Class. |
17 | |
a9c8094b |
18 | =cut |
19 | |
20 | my %method2key = ( |
21 | name => 'type', |
22 | class => 'self_class', |
23 | accessor => 'accessor', |
24 | foreign_class => 'class', |
25 | ); |
26 | |
27 | sub new { |
28 | my($class, $args) = @_; |
29 | |
30 | return bless $args, $class; |
31 | } |
32 | |
33 | for my $method (keys %method2key) { |
34 | my $key = $method2key{$method}; |
35 | my $code = sub { |
36 | $_[0]->{$key}; |
37 | }; |
38 | |
39 | no strict 'refs'; |
40 | *{$method} = $code; |
41 | } |
42 | |
43 | sub args { |
44 | warn "args() is unlikely to ever work"; |
45 | return undef; |
46 | } |
47 | |
48 | |
49 | 1; |