Class::...structor(3)

πŸ’– Class::MOP::Method::Constructor πŸ’–

okay bestie, so this page is Class::MOP::Method::Constructor from the User Contributed Perl Documentation corner of the perl man pages, and it's literally the method meta object that builds your constructors ✨ no cap


🌸 NAME 🌸

Class::MOP::Method::Constructor β€” Method Meta Object for constructors πŸ’…

like. it's the meta object. for constructors. that's the whole vibe.


πŸŽ€ VERSION πŸŽ€

version 2.4000 β€” yeah she's on 2.4000, keep up 🫢


✨ SYNOPSIS ✨

here's how you actually use her, copy-paste style:

use Class::MOP::Method::Constructor;

my $constructor = Class::MOP::Method::Constructor->new(
    metaclass => $metaclass,
    options   => {
        debug => 1, # this is all for now
    },
);

# calling the constructor ...
$constructor->body->execute($metaclass->name, %params);

yes the debug => 1 comment literally says "this is all for now" and honestly? iconic. lowkey relatable. she's doing her best πŸ₯Ί


🌈 DESCRIPTION 🌈

okay so Class::MOP::Method::Constructor is a subclass of Class::MOP::Method, and what she does β€” her whole main character thing β€” is generate constructor methods. that's it. that's the job. and she eats every time πŸ’…πŸ”₯


πŸ‘‘ METHODS πŸ‘‘

πŸ’œ Class::MOP::Method::Constructor->new(%options)

this is the glow-up moment: she creates a brand new constructor object. hand her a hash reference of options and she's good to go ✨

here's the tea on those options:

  • metaclass β€” this one should be a Class::MOP::Class object. and it's required, bestie, no skipping it πŸ™…
  • name β€” the method name, and without a package name (just the name, ok?). also required πŸ’–
  • package_name β€” the package name for the method. yep. required too 🫢
  • is_inline β€” this tells her whether or not the constructor should be inlined. it defaults to false, so if you don't say anything she's not inlining, periodt.

πŸ’– $metamethod->is_inline

returns a boolean that says whether or not the constructor is inlined. true or false, that's the whole answer, no essay required πŸ“


πŸ¦‹ $metamethod->associated_metaclass

this one hands you back the Class::MOP::Class object for the method. like, the metaclass that's associated. hence the name. slay πŸ’…


🌟 AUTHORS 🌟

look at this roster, it's giving collaborative masterpiece, the way so many people poured into this πŸ˜­πŸ’–

  • 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. we stan every single one πŸ«ΆπŸ‘‘


so, legal bit but make it cute:

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

and the license tea:

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

tl;dr: free software, same terms as perl 5 itself, go wild (responsibly) 🌈


and that's the whole page, bestie!! this was Class::...structor(3) πŸ’–βœ¨ from perl v5.42.0, dated 2025-07-25 β€” mwah, love that for us, bye!! πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from