Class::Gomor(3pm)
π Class::Gomor π
okay bestie, gather round, because this is Class::Gomor β another class and object builder, from perl's User Contributed Perl Documentation, living in section 3pm like the icon it is. she's not like the other class builders, and you're gonna see why. π
β¨ NAME β¨
Class::Gomor β another class and object builder. yes, that's literally it, she says what she is. π
πΈ DESCRIPTION πΈ
so this module is yet another class builder, right, but here's the twist that makes her special: she adds parameter checking in the new constructor. like, she actually checks that your attributes exist, and that they're defined. she's looking out for you fr fr. π«Ά
and the way she validates params? she needs to find the attributes first, which is the entire reason you declare them in global variables named @AS, @AA and @AO. they respectively stand for Attributes Scalar, Attributes Array, and Attributes Other. that last one (@AO) exists so you can avoid autocreation of accessors β basically it lets you declare your own ones, your own way, no notes. π
the attribute validation happens by looking at the classes hierarchy, following the @ISA tree inheritance. it's giving detective energy honestly. π
now, the loss in speed from validating all attributes is quite negligeable on a decent machine (they say Pentium IV, 2.4 GHz, with Perl 5.8.x β vintage vibes, we love a throwback). but if you want to avoid checking entirely, you absolutely can, see below bestie. π
also important: this class is the base class for Class::Gomor::Array and Class::Gomor::Hash, so those two will inherite the following methods. slay. π
π GLOBAL VARIABLES π
$NoCheckβ import it into your namespace like this:
use Class::Gomor qw($NoCheck);
if you want to disable cgCheckParams to improve speed once your program is frozen, this is your girl. set it to 1 to disable parameter checking. bye bye validation, hello speed. π₯
$Debugβ import it into your namespace like this:
use Class::Gomor qw($Debug);
this variable is used by the cgDebugPrint method. that's the whole vibe. β¨
π¦ METHODS π¦
cgCheckParams (hash ref, array ref)β the attribute checking method, and she takes two arguments: the first is user passed attributes (as a hash reference), the second is the list of valid attributes, gathered via thecgGetAttributesmethod (as an array ref). if the passed parameters are not valid, a message gets displayed. she will literally tell you. πcgGetIsaTree (array ref)β a recursive method. you pass a class in an array reference as an argument, and then the@ISAarray gets browsed, recursively. the array reference you passed as an argument is increased with new classes, pushed into it. it returns nothing β the result is stored in the array ref. sneaky but effective. πcgGetAttributesβ this method returns available attributes for the caller's object class. it usescgGetIsaTreeto search recursively in class hierarchy. then it returns an array reference with all possible attributes. the full roster. πcgBuildAccessorsScalar (array ref)β accessor creation method. takes an array reference containing all scalar attributes to create. scalar accessors are stored in a global variable names@AS. so you call this method at the beginning of your class like that:
__PACKAGE__->cgBuildAccessorsScalar(\@AS);
cgBuildAccessorsArray (array ref)β accessor creation method. takes an array reference containing all array attributes to create. array accessors are stored in a global variable names@AA. so you call this method at the beginning of your class like that:
__PACKAGE__->cgBuildAccessorsArray(\@AA);
cgClone [ (scalar) ]β you can clone one of your objects by calling this method. an optional parameter may be used to create multiple clones. but heads up: cloning will occure only on the first level attributes, that is, if you have attributes containing other objects, they will not be cloned. shallow queen behavior, know that going in. πcgFullClone [ (scalar) ]β this method is the same ascgClone, but will clone all attributes recursively β but only if they are subclassed fromClass::Gomor. so objects created with other modules thanClass::Gomor::ArrayorClass::Gomor::Hashwill not be cloned. ngl that's the boundary, respect it.
another thing to note: there is no catch for cycling references (when you link two objects with each others). you have been warned. πππ
cgDebugPrint (scalar, scalar)β first argument is a debug level. it gets compared with global$Debug, and if it's less than it, the second argument (a message string) is displayed. this method exists because the author uses it β maybe you will not like it. honestly? fair. π
π₯ SEE ALSO π₯
Class::Gomor::Array, Class::Gomor::Hash
the whole family, go say hi. π«Ά
π AUTHOR π
Patrice <GomoR> Auffret β the legend herself. π
π COPYRIGHT AND LICENSE π
Copyright (c) 2004-2015, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.
and that's the whole page bestie, no cap, every last detail. this was perl v5.36.0, dated 2022-10-13 β mwah, iconic, periodt. πβ¨π
π¦ where this page comes from
- ubuntu noble: libclass-gomor-perl 1.03-3 Β· Artistic-1.0-Perl
- ubuntu resolute: libclass-gomor-perl 1.03-3 Β· Artistic-1.0-Perl
- ubuntu stonking: libclass-gomor-perl 1.03-3 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms