Updated HasMany.pm
[prev]
[thread]
[next]
[Date index for 2005/06/13]
--Oiv9uiLrevHtW1RS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
Attached is an updated version of HasMany.pm, that gets rid of
the use of deprecated ::Query module, and deprecates the class
has_many accessor. It uses the search function of the foreign
class, so it is possible to override the behaviour by subclassing.
The 09has_many test passes with the has_many tests switched to HasManyExt.
Please let me know if this can be included in CDBI.
Cheers,
CLK
--Oiv9uiLrevHtW1RS
Content-Type: application/x-perl
Content-Disposition: attachment; filename="HasManyExt.pm"
Content-Transfer-Encoding: quoted-printable
package Class::DBI::Relationship::HasManyExt;=0A=0Ause strict;=0Ause warnin=
gs;=0A=0Ause base 'Class::DBI::Relationship::HasMany';=0A=0A# returns forei=
gn class and criteria to use for loading the has_many target=0Asub accessor=
_info {=0A my ($pkg, $obj, $field) =3D @_;=0A my $meta =3D $obj->meta=
_info(has_many =3D> $field);=0A return ($meta->foreign_class,=0A { $=
meta->args->{foreign_key} =3D> $obj },=0A $meta->args);=0A}=0A=0Asub _h=
m_run_search {=0A my $self =3D shift;=0A my ($class, $accessor)=
=3D ($self->class, $self->accessor);=0A=0A return sub {=0A my $me =3D s=
hift;=0A my ($f_class, $search, $args) =3D $self->accessor_info($me, $acces=
sor);=0A die 'Class has_many accessor deprecated' unless ref($me);=0A $f_cl=
ass->search(%$search, @_, $args);=0A }=0A}=0A=0A1;=0A
--Oiv9uiLrevHtW1RS--
|
Updated HasMany.pm
Chia-liang Kao 12:50 on 13 Jun 2005
|