NAME
MooseX::Marlin - 🫎 ❤️ 🐟 inherit from Marlin classes in Moose
SYNOPSIS
use v5.20.0;
no warnings "experimental::signatures";
package Person {
use Types::Common -lexical, -all;
use Marlin::Util -lexical, -all;
use Marlin
'name' => { is => ro, isa => Str, required => true },
'age' => { is => rw, isa => Int, predicate => true };
}
package Employee {
use Moose;
use MooseX::Marlin;
extends 'Person';
has employee_id => ( is => 'ro', isa => 'Int', required => 1 );
}
WARNING
This appears to work, but it is not thoroughly tested.
DESCRIPTION
Loading this class will do a few things:
Ensures you are using at least Moose 2.2004 (released in January 2017).
Loop through all Marlin classes and roles which have already been defined (also any foreign classes like Class::Tiny ones which Marlin has learned about by inheritance, etc) and inject metadata about them into Class::MOP, enabling them to be used by Moose.
Tells Marlin to keep injecting metadata into Class::MOP for any Marlin classes or roles that are loaded later.
Checks that the caller package is a Moose class or Moose role, and complains otherwise. (Make sure to
use Mooseoruse Moose::Rolebefore youuse MooseX::Marlin!)Imports
new,does,BUILDARGS,BUILDALL, andDEMOLISHALLfrom Moose::Object into the caller package, if the caller package is a Moose class.
It is possible to list additional foreign classes on the use MooseX::Marlin line to force Marlin to learn about them. This can allow Moose to inherit some non-Moose classes, like classes built by Mouse or Class::Tiny.
In the following example use MooseX::Marlin qw( Local::Squeak ) not only allows Local::Squash to inherit from Marlin classes, but also disguises Local::Squeak as a Marlin class. (Moose cannot normally inherit from Mouse classes!)
BEGIN {
package Local::Squeak;
use Mouse;
has squeak => ( is => 'ro', isa => 'Int' );
};
BEGIN {
package Local::Squash;
use Moose;
use MooseX::Marlin qw( Local::Squeak );
extends 'Local::Squeak';
has squash => ( is => 'ro', isa => 'Int' );
__PACKAGE__->meta->make_immutable;
};
use Data::Dumper;
$Data::Dumper::Deparse = 1;
print Dumper( Local::Squash->can('new') );
my $o = Local::Squash->new( squeak => 1, squash => 2 );
print Dumper( $o );
BUGS
Please report any bugs to https://github.com/tobyink/p5-marlin/issues.
SEE ALSO
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2026 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.