Rose::Class(3pm)

πŸ“¦
version 0.860 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Rose::Class πŸ’–

okay bestie, welcome to Rose::Class β€” it's a very simple class base class, and no, that's not a typo, that's literally the whole vibe. it's giving "user contributed perl documentation" energy and honestly? iconic. πŸŽ€


✨ SYNOPSIS ✨

here's the whole thing in action, no cap:

package MyClass;

use Rose::Class;
our @ISA = qw(Rose::Class);

sub foo { ... }
...

MyClass->foo(...) or die MyClass->error;
...

see how we use Rose::Class, drop it in @ISA, do our little foo thing, and then check MyClass->error when stuff goes sideways? that's the whole relationship. 🫢


🌸 DESCRIPTION 🌸

so like, Rose::Class is a generic base class for classes. it hands you exactly one class method (error), and it might get more stuff later β€” it "may be expanded further in the future" β€” so don't come for it, it's growing. 🌱

here's the part you need to actually internalize though, bestie: a class that inherits from Rose::Class is not expected to allow objects of that class to be instantiated, because the namespace for class methods and object methods is shared. it's one namespace, one house, everybody living in it. 🏠

for example β€” and this is the classic case β€” it's common for Rose::Object-derived classes to have their own error methods. but that would conflict with the Rose::Class method of the same name. two errors, one namespace, absolutely not the moment. πŸ’€


πŸ‘‘ CLASS METHODS πŸ‘‘

  • error [ERROR] β€” get or set the class-wide error. by convention this should be a scalar that stringifies to an error message, and the most commonly used value is just a simple scalar containing a string. like, a plain string. that's it. that's the whole thing. simple, clean, slay. ✨

πŸ¦‹ AUTHOR πŸ¦‹

John C. Siracusa (siracusa@gmail.com) β€” king behavior, honestly. πŸ‘‘


πŸŽ€ LICENSE πŸŽ€

Copyright (c) 2010 by John C. Siracusa. All rights reserved. this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. periodt. πŸ’…


🌈 and that's the page, bestie β€” go forth and set your class-wide errors responsibly. πŸ“

this was perl v5.34.0, dated 2022-05-28, signing off from the Rose::Class(3pm) corner of the internet πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from