RE: Inflating and deflating
[prev]
[thread]
[next]
[Date index for 2005/02/14]
This is a multi-part message in MIME format.
------_=_NextPart_001_01C51292.635B4D39
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
From: Perrin Harkins Sent: Thu 10/02/2005 18:03
> On Thu, 2005-02-10 at 17:52 +0000, Addison, Mark wrote:
> > Sorry if I'm being dense, but I thought that was the whole point
> > of the alias that Class::Accessor (therefore CDBI) creates!
> > ie you can define a method with the _same_ name as the CDBI created
> > accessor and then use the alias method to call the origional CDBI
> > generated one. Is there a gotcha with this I'm missing?
>
> Don't you get a warning when you redefine that sub? They are both being
> put into the same namespace.
No, Class::Accessor sorts it. It installs the method under both names
(e.g. foo and _foo_accessor) but only if that name hasn't already be
used (ie by your own sub). Works fine as long as don't call any of your
own methods _*_accessor.
From Class/Accessor.pm
my $accessor =3D $self->$maker($field);
my $alias =3D "_${field}_accessor";
*{$class."\:\:$field"} =3D $accessor
unless defined &{$class."\:\:$field"};
*{$class."\:\:$alias"} =3D $accessor
unless defined &{$class."\:\:$alias"};
mark
--
This email (and any attachments) is intended solely for the individual(s) t=
o whom addressed.=20
It may contain confidential and/or legally privileged information.=20
Any statement or opinions therein are not necessarily those of ITN unless s=
pecifically stated.=20
Any unauthorised use, disclosure or copying is prohibited.=20
If you have received this email in error, please notify the sender and dele=
te it from your system.=20
Security and reliability of the e-mail and attachments are not guaranteed.=20
You must take full responsibility for virus checking.
Independent Television News Limited,=20
Registered No. 548648 England,
VAT Reg. No: GB 756 2995 81,=20
200 Gray's Inn Road, London WC1X 8XZ,
Telephone: 020 7833 3000.
------_=_NextPart_001_01C51292.635B4D39
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Diso-8859-=
1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 6.5.6980.19">
<TITLE>RE: Inflating and deflating</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=3D2>From: Perrin Harkins Sent: Thu 10/02/2005 18:03<BR>
> On Thu, 2005-02-10 at 17:52 +0000, Addison, Mark wrote:<BR>
> > Sorry if I'm being dense, but I thought that was the whole point<=
BR>
> > of the alias that Class::Accessor (therefore CDBI) creates!<BR>
> > ie you can define a method with the _same_ name as the CDBI creat=
ed<BR>
> > accessor and then use the alias method to call the origional CDBI=
<BR>
> > generated one. Is there a gotcha with this I'm missing?<BR>
><BR>
> Don't you get a warning when you redefine that sub? They are bot=
h being<BR>
> put into the same namespace.<BR>
<BR>
No, Class::Accessor sorts it. It installs the method under both names<BR>
(e.g. foo and _foo_accessor) but only if that name hasn't already be<BR>
used (ie by your own sub). Works fine as long as don't call any of your<BR>
own methods _*_accessor.<BR>
<BR>
From Class/Accessor.pm<BR>
<BR>
my $acce=
ssor =3D $self->$maker($field);<BR>
my $alia=
s =3D "_${field}_accessor";<BR>
<BR>
*{$class=
."\:\:$field"} =3D $accessor<BR>
&nb=
sp; unless defined &{$class."\:\:$field"};<BR>
<BR>
*{$class=
."\:\:$alias"} =3D $accessor<BR>
&nb=
sp; unless defined &{$class."\:\:$alias"};<BR>
<BR>
mark<BR>
--<BR>
</FONT>
</P>
<pre>This email (and any attachments) is intended solely for the individual=
(s) to whom addressed.=20
It may contain confidential and/or legally privileged information.=20
Any statement or opinions therein are not necessarily those of ITN unless s=
pecifically stated.=20
Any unauthorised use, disclosure or copying is prohibited.=20
If you have received this email in error, please notify the sender and dele=
te it from your system.=20
Security and reliability of the e-mail and attachments are not guaranteed.=20
You must take full responsibility for virus checking.
Independent Television News Limited,=20
Registered No. 548648 England,
VAT Reg. No: GB 756 2995 81,=20
200 Gray's Inn Road, London WC1X 8XZ,
Telephone: 020 7833 3000.
</pre></BODY>
</HTML>
------_=_NextPart_001_01C51292.635B4D39--
|
|
RE: Inflating and deflating
Addison, Mark 12:40 on 14 Feb 2005
|