MooseX::Deprecated(3)

πŸ“¦
version 0.005 Β· 2 versions
, in fedora 43

πŸ’– MooseX::Deprecated πŸ’–

okay bestie, so this is MooseX::Deprecated β€” the User Contributed Perl Documentation page for it β€” and it does exactly one thing but it does it so well: it marks attributes and methods as deprecated. periodt.


✨ NAME ✨

MooseX::Deprecated β€” mark attributes and methods as deprecated πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

package Goose
{
   use Moose;

   has feathers => (is => 'ro');

   sub honk { say "Honk!" }

   with "MooseX::Deprecated" => {
      attributes => [ "feathers" ],
      methods    => [ "honk" ],
   };
}

like. look at that. your goose is fabulous and also on notice. πŸͺΏ


🌸 DESCRIPTION 🌸

MooseX::Deprecated is a parameterizable role that makes it easy to deprecate particular attributes and methods in a class. no cap, that's the whole vibe.

In the SYNOPSIS up there, before method modifiers get installed on the feathers accessor and on the honk method, and they issue a deprecation warning. plus β€” and this is the part that ate β€” an after modifier gets installed on the class' BUILD method, which issues deprecation warnings for any deprecated attributes you pass to the constructor. so you can't sneak around the back either, bestie. πŸ™ˆ

The warning text will be something along the lines of:

%s is a deprecated %s

Warnings are issued in the deprecated warnings category, so you can turn them off with:

no warnings qw( deprecated );

and you can glow them up into fatal errors with:

use warnings FATAL => qw( deprecated );
⚠️ heads up: warnings will only be issued once per call site. not once per call. once per site. iykyk.

When consuming the role you must pass either a list of attributes, or a list of methods, or both, as parameters to the role. if you forget β€” and bestie, you will forget β€” you'll get an error message like:

%s with no list of attributes or methods

πŸ’€ CAVEATS πŸ’€

okay so this is the part where we sit down. 🫢

To deprecate an attribute, the attribute must actually exist at the time you consume this role. In particular, this will not work:

package Goose
{
   use Moose;

   with "MooseX::Deprecated" => {
      attributes => [ "feathers" ],
   };

   has feathers => (is => 'ro');
}

Because the feathers attribute isn't defined until after the role is consumed. ordering matters, it's giving main character energy for the with statement. Attempting the above will die with a nasty error message:

Attribute %s does not exist in %s so cannot be deprecated

😭 she's dramatic but she's right.

If a deprecated attribute handles any methods via delegation, then calling these methods will result in not one, but two warnings. One warning for calling the delegated method; the other warning for calling the accessor (reader) to obtain the object to delegate to. This could theoretically be changed, but the author is comfortable with the existing situation. honestly? respect. πŸ’…

Warnings issued by the accessor (reader) during method delegation come from inside your class, and thus the caller cannot disable them or fatalize them. you don't get to vibe check those ones. 🚫


πŸ› BUGS πŸ›

Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=MooseX-Deprecated>. do it for her. 🫢

πŸ•°οΈ Perl 5.8 πŸ•°οΈ

The behaviour of warnings::warnif changed significantly between Perl 5.8 and Perl 5.10; the location considered to be the effective caller changed from being like warn to being like carp (the latter being considerably more useful). Therefore under Perl 5.8, doing things like no warnings "deprecated" in your code to control warnings from this role is rather useless, because your code is unlikely to be considered to be the caller. literally pointless bestie.

In the test suite the author just skips the complex test that checks for this on Perl prior to 5.10, allowing you to install this module without a hitch on Perl 5.8. However, you are strongly discouraged from using this module with Perl 5.8. like, strongly. 🚩


🌈 SEE ALSO 🌈

  • Package::DeprecationManager provides a more powerful and complicated set of features. the author is a simple kind of guy, and doesn't see the need to allow his caller to pick and choose which deprecations they'd like to ignore based on some API version. simple. iconic. πŸ‘‘
  • Attribute::Deprecated is cute, but only deals with methods, and ironically not (what Moose calls) attributes. the irony is thick. πŸ’€
  • Devel::Deprecation has some pretty nice features, but is more manual than the author would like, and again only deals with methods.
  • Not to be confused with Moose::Deprecated which can be used to manage warnings issued by Moose itself. ⚠️ different girl, same name energy.
  • <http://en.wikipedia.org/wiki/Self-deprecation>. yes really. 🌸

πŸŽ€ AUTHOR πŸŽ€

Toby Inkster <tobyink@cpan.org>. 🫢


This software is copyright (c) 2013-2014 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay. ✨


🚨 DISCLAIMER OF WARRANTIES 🚨

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

no warranty bestie. none. zero. nada. she's perfect but she comes as-is. 😭

and that's the whole page, mwah πŸ’… this one was rendered by perl v5.42.0 and dated 2025-07-25 β€” go forth and deprecate responsibly, my love πŸ¦‹βœ¨

πŸ“¦ where this page comes from