Moose::...seParent(3)

πŸ’– NAME πŸ’–

Moose::Cookbook::Basics::DateTime_ExtendingNonMooseParent β€” ok bestie, this is the one where we extend a parent class that is not Moose-based. The manual page itself lives at Moose::...seParent(3) in the User Contributed Perl Documentation section, and it's literally titled "Extending a non-Moose parent class". Periodt. πŸ¦‹


✨ VERSION ✨

version 2.4000 β€” yes she's on 2.4000, no cap. πŸŽ€


🌸 SYNOPSIS 🌸

Like, here's the whole vibe, verbatim, don't touch a single character:

  package My::DateTime;

  use Moose;
  use MooseX::NonMoose;
  use DateTime::Calendar::Mayan;
  extends qw( DateTime );

  has 'mayan_date' => (
      is        => 'ro',
      isa       => 'DateTime::Calendar::Mayan',
      init_arg  => undef,
      lazy      => 1,
      builder   => '_build_mayan_date',
      clearer   => '_clear_mayan_date',
      predicate => 'has_mayan_date',
  );

  after 'set' => sub {
      $_[0]->_clear_mayan_date;
  };

  sub _build_mayan_date {
      DateTime::Calendar::Mayan->from_object( object => $_[0] );
  }

Look at her. A whole Mayan calendar attribute riding shotgun on a DateTime subclass. Iconic behavior honestly. πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

So this recipe is a whole tutorial on how to use Moose to subclass a parent that is not Moose based. That's the tea. 🍡

Important caveat, bestie, do NOT skip this: this recipe only works if the parent class uses a blessed hash reference for object instances. That's the hard requirement. If your parent is doing something funkier than that, you should check out MooseX::NonMoose::InsideOut and MooseX::InsideOut instead. Fr fr.

The meat of this recipe β€” like, the actual substance, the protein of the whole thing β€” is contained in MooseX::NonMoose, which does all the grunt work for you. You just sit there and look pretty while it handles everything. 🌈


🫢 AUTHORS 🫢

Shoutout to the whole friend group who made this happen, in order:

  • Stevan Little <stevan@cpan.org>
  • Dave Rolsky <autarch@urth.org>
  • Jesse Luehrs <doy@cpan.org>
  • Shawn M Moore <sartak@cpan.org>
  • Χ™Χ•Χ‘Χœ Χ§Χ•Χ’'מן (Yuval Kogman) <nothingmuch@woobling.org>
  • Karen Etheridge <ether@cpan.org>
  • Florian Ragwitz <rafl@debian.org>
  • Hans Dieter Pearcey <hdp@cpan.org>
  • Chris Prather <chris@prather.org>
  • Matt S Trout <mstrout@cpan.org>

Ten whole legends. The way that they all showed up for this one cookbook recipe… main character energy from every single one of them. πŸ˜­πŸ’–


This software is copyright (c) 2006 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So like, go off, remix it, slay. 🧚


And that's the whole page, bestie! This one shipped as perl v5.42.0, dated 2025-07-25, living under the name Moose::...seParent(3). Mwah, ily, go extend something that isn't Moose. πŸ’œβœ¨

πŸ“¦ where this page comes from