[Dbix-class] Where to define constants.
Bill Moseley
moseley at hank.org
Sat Apr 24 15:21:52 GMT 2010
On Sat, Apr 24, 2010 at 2:34 AM, Ian <dbix-class at iandocherty.com> wrote:
>
> My current solution is to have a MooseX::Singleton class that defines all
> constants used in my database (and perhaps elsewhere in my application).
> e.g.
>
> sub foo_track_type_count {
> return shift->tracks( {
> track_type =3D> $constant->track_type_foo,
> })->count;
> }
>
Thanks, Ian. I like that approach as it's very clear a constant is being
used and it avoids importing symbols. And another excuse to use Moose.
I'll avoid the discussion that it's "slow" because I can only access the
constant at 168,634.06/s compared to 6,802,721.09/s with "constant" pragma.
;)
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100424/f53=
963a0/attachment.htm
More information about the DBIx-Class
mailing list