NAME
TUI::toolkit::UO::Antlers - Moose-like sugar for UNIVERSAL::Object
VERSION
version 0.08
DESCRIPTION
UNIVERSAL::Object is a wonderful base class. The author Stevan Little has added the pragma slots for practical use, which is based on the MOP distribution. In my opinion, this combination made the usage not as light-footed as it could be.
This is why this Module was developed, which does not require the MOP distribution.
Similar to the fields pragma, TUI::toolkit::UO::Antlers declares individual fields (stored in a global variable %HAS). UNIVERSAL::Object is used as the base class, and access methods can be created using an has keyword.
This module also recognizes the superclasses of a class and ensures that their fields are inherited correctly. Inheritance occurs automatically if you use extends to set up the class hierarchy.
FUNCTIONS
has
An Moose-like form: has name => ( key => value, ... ), allowing additional slot options such as read/write accessors and custom default generators.
has x => ( is => 'rw', default => sub { 1 } );
has y => ( is => 'ro', default => sub { 2 } );
The form always begins with the has keyword and the name, followed by an odd-length list of option/value pairs. Supported options are:
is-
Specifies the accessor type. Allowed values are
'ro','rw'and'bare'. If omitted,'rw'is assumed. When available, Class::XSAccessor is used to generate the class accessors. If environment variablePERL_ONLYis set, the pure Perl implementation will be used. default-
A CODE reference that generates the default value for the slot.
extends
The extends function adds the given parent classes to the caller's @ISA. For example:
package Foo;
use TUI::toolkit::UO::Antlers;
extends 'Bar', 'Baz';
EXPORTS
The following functions are exported by default:
blessedfrom Scalar::Utilconfessfrom Carp
It uses Exporter to export the functions has, extends, blessed and confess.
DEPENDENCIES
MRO::Compat when using perl < v5.10
LIMITATIONS
This Module creates the global variable %HAS used by UNIVERSAL::Objects. This means that all derived classes will require %HAS (including inherited entries), even if no new fields are added.
The simplest way to achieve this is by consistently using use TUI::toolkit::UO::Antlers. The import routine creates the global variable %HAS and initializes the necessary entries.
SEE ALSO
UNIVERSAL::Object, Class::Fields::Fuxor, Class::Fields::Inherit.
AUTHOR
J. Schneider <brickpool@cpan.org>
CONTRIBUTORS
Stevan Little <stevan@cpan.org>
Michael G Schwern <schwern@pobox.com>
LICENSE
Copyright (c) 2024-2026 the "AUTHORS" and "CONTRIBUTORS" as listed above.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.