| 1 | package OpenERP::OOM::Link::Provider; | ||
| 2 | |||
| 3 | 2 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 2 | requires 'provide_link'; | |
| 6 | 2 | with 'OpenERP::OOM::DynamicUtils'; | |
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | OpenERP::OOM::Link::Provider | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | This is the role for a link provider that provides a way to link another dataset, | ||
| 15 | normally a DBIC dataset. | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | package MyLinkProvider; | ||
| 20 | |||
| 21 | use Moose; | ||
| 22 | with 'OpenERP::OOM::Link::Provider'; | ||
| 23 | |||
| 24 | sub provide_link | ||
| 25 | { | ||
| 26 | my ($self, $class) = @_; | ||
| 27 | |||
| 28 | my $package = ($class =~ /^\+/) ? $class : "OpenERP::OOM::Link::$class"; | ||
| 29 | |||
| 30 | eval "use $package"; | ||
| 31 | $self->ensure_class_loaded($package); | ||
| 32 | |||
| 33 | return $package->new( | ||
| 34 | schema => $self, | ||
| 35 | config => $self->link_config->{$class}, | ||
| 36 | ); | ||
| 37 | } | ||
| 38 | |||
| 39 | 1; | ||
| 40 | |||
| 41 | =head1 COPYRIGHT and LICENSE | ||
| 42 | |||
| 43 | Copyright (C) 2011 OpusVL | ||
| 44 | |||
| 45 | This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | 2 | 1; | |