Class:...ntlers(3pm)
β¨ NAME β¨
Class::Tiny::Antlers β Moose-like sugar for Class::Tiny, and yes bestie it's giving exactly what you think it's giving π
It's a Perl module, Class:...ntlers(3pm) if you're looking it up in the man pages, and it exists purely to make Class::Tiny feel like its glamorous Moose cousin.
πΈ SYNOPSIS πΈ
{
package Point;
use Class::Tiny::Antlers;
has x => (is => 'ro');
has y => (is => 'ro');
}
{
package Point3D;
use Class::Tiny::Antlers;
extends 'Point';
has z => (is => 'ro');
}
Look at that. Clean. Cozy. No boilerplate trauma. π«Ά
π DESCRIPTION π
Okay so here's the tea: Class::Tiny::Antlers hands you Moose-like has, extends, with, before, after and around keywords, but for Class::Tiny. Best of both worlds fr fr.
Heads up though: the with keyword needs Role::Tiny, and the method modifiers need Class::Method::Modifiers. Not optional. That's the deal. π
Now, Class::Tiny does not support every single Moose attribute option in existence, and has should throw you an error if you try to do something it doesn't support (like triggers). So don't come for it when it yells at you, it's literally just doing its job. π
But here's where it gets cute: Class::Tiny::Antlers does hack in support for is => 'ro' and Moo-style is => 'rwp', plus clearers and predicates. Slay. β¨
And from version 0.24, Class::Tiny::Antlers also adds support for isa and coerce using Type::Tiny. (I mean, this is a TOBYINK module, so what do you expect?!) π Technically MooseX::Types, MouseX::Types, Specio, and Type::Nano should work too, but those are less tested. Lowkey experimental energy, you've been warned.
π Export π
By default, Class::Tiny::Antlers exports has, with and extends, and it also imports strict into its caller. Free strict, no cap. π₯
You can optionally also import confess and warnings:
use Class::Tiny::Antlers qw( -default confess warnings );
And you can pull in the Class::Method::Modifiers keywords:
use Class::Tiny::Antlers qw( -default before after around );
use Class::Tiny::Antlers qw( -default -cmm ); # same thing
(Yes those two lines do the exact same thing. -cmm is just the shorthand, iykyk.)
And if you just want everything:
use Class::Tiny::Antlers qw( -all );
Go off, main character. π
Class::Tiny::Antlers also makes sure that Class::Tiny's import method gets called for your class. It's got your back.
Oh and btw, you can drop a no Class::Tiny::Antlers statement at the end of your class definition to wipe the imported functions right out of your namespace. Poof. Gone. π¦
Careful though: this does not unimport strict/warnings. Those are staying, bestie. If you want a thorough namespace cleanup, use something like namespace::sweep.
π§ Functions π§
has $attr, %specβ Creates an attribute. The specification hash roughly supportsis,default,clearerandpredicateas per Moose and Moo.extends @classesβ Sets the base class(es) for your class. Your whole lineage, sorted. πwith @rolesβ Composes Role::Tiny roles with your class. Mixing in that flavor. πbefore $name, \&codeβ Installs abeforemodifier using Class::Method::Modifiers.after $name, \&codeβ Installs aaftermodifier using Class::Method::Modifiers.around $name, \&codeβ Installs aaroundmodifier using Class::Method::Modifiers.confess $format, @listβ Asprintf-fueled version of Carp'sconfess. It will tell you what went wrong, and it will do it with formatting. π
π Methods π
Class::Tiny::Antlers inherits the get_all_attributes_for and get_all_attribute_defaults_for methods from Class::Tiny, and it also provides this one:
Class::Tiny::Antlers->get_all_attribute_specs_for($class)β Gets Moose-style attribute specification hashes for all the class' attributes as one big hashref. (Includes inherited attributes, so you get the whole family tree, not just the immediate vibes.) πΈ
π BUGS π
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Class-Tiny-Antlers>.
Not me asking you to snitch, but like... kindly. π
β SEE ALSO β
Class::Tiny, Role::Tiny, Class::Method::Modifiers, Type::Tiny::Manual.
Moose, Mouse, Moo.
The whole friend group, honestly. π«Ά
π AUTHOR π
Toby Inkster <tobyink@cpan.org>.
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2013, 2019 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.
π 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.
Read it and weep, because there's genuinely no warranty. It said what it said. π
That's the whole page, bestie β perl v5.36.0, dated 2022-12-08, from the Class:...ntlers(3pm) corner of the User Contributed Perl Documentation. Go write some attributes, you absolute icon. β¨π¦π
π¦ where this page comes from
- debian bookworm: libclass-tiny-antlers-perl 0.024-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libclass-tiny-antlers-perl 0.024-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libclass-tiny-antlers-perl 0.024-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libclass-tiny-antlers-perl 0.024-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libclass-tiny-antlers-perl 0.024-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms