App::C...:Status(3pm)

πŸ“¦
version 0.231 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

πŸ’– App::C...:Status(3pm) πŸ’–

okay bestie, welcome to App::C...:Status(3pm) β€” the Perl doc for App::CELL::Status, aka the class that makes your return values have ✨feelings✨ and a whole personality. she's giving "I return a value AND I tell you how it went." iconic behavior fr fr.


✨ NAME ✨

App::CELL::Status β€” class for return value objects πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

use App::CELL::Status;

# simplest usage
my $status = App::CELL::Status->ok;
print "ok" if ( $status->ok );
$status = App::CELL::Status->not_ok;
print "NOT ok" if ( $status->not_ok );

# as a return value: in the caller
my $status = $XYZ( ... );
return $status if not $status->ok;  # handle failure
my $payload = $status->payload;     # handle success

like. look at her. she's a whole return-value ecosystem and she's serving πŸ’…


🌸 INHERITANCE 🌸

This module inherits from App::CELL::Message. so yeah, she's got a parent and she's carrying on the family legacy 🫢


πŸ‘‘ DESCRIPTION πŸ‘‘

An App::CELL::Status object is a reference to a hash containing some or all of the following keys (attributes):

  • "level" β€” the status level (peep "new" below, bestie)
  • "message" β€” message explaining the status
  • "caller" β€” an array reference containing the three-item list generated by the "caller" function

The typical use cases for this object are, and I quote the vibes:

  • As a return value from a function call
  • To trigger a higher-severity log message
🚨 All calls to "App::CELL::Status->new" with a status other than OK trigger a log message. no cap. she will be loud about it.

🧚 PUBLIC METHODS 🧚

This module provides the following public methods. buckle up, there's lore.

πŸ“ new

Construct a status object and trigger a log message if the level is anything other than "OK". Always returns a status object. If no level is specified, the level will be 'ERR'. If no code is given, the code will be undefined (I think). πŸ’€

yes the "(I think)" is literally in the original docs and honestly? relatable. we love an honest queen.

πŸ“ dump

Dump an existing status object. Takes: PARAMHASH. Parameter 'to' determines destination, which can be 'string' (default), 'log' or 'fd'.

# dump object to string
my $dump_str = $status->dump();
   $dump_str = $status->dump( to => 'string' );

# dump object to log
$status->dump( to => 'log' );

# dump object to file descriptor
$status->dump( fd => STDOUT );
$status->dump( to => 'fd', fd => \*STDOUT );

Always returns a true value. always. she's reliable like that πŸ’œ

πŸ“ ok

If the first argument is blessed, assume we're being called as an instance method: return true if status is OK, false otherwise.

Otherwise, assume we're being called as a class method: return a new OK status object with optional payload (optional parameter to the method call, must be a scalar).

so she reads the room first and then decides who she is. main character energy honestly 🌈

πŸ“ not_ok

Similar method to 'ok', except it handles 'NOT_OK' status. πŸ™ˆ

When called as an instance method, returns a true value if the status level is anything other than 'OK'. Otherwise false.

When called as a class method, returns a 'NOT_OK' status object. Optionally, a payload can be supplied as an argument.

πŸ“ level

Accessor method, returns level of status object in ALL-CAPS. All status objects must have a level attribute.

ALL-CAPS. she is NOT whispering about her level. πŸ“£

πŸ“ code

Accesor method, returns code of status object, or "<NONE>" if none present.

(yes, "Accesor" β€” that's how it's spelled in here, and I'm keeping it exactly, don't come for me 😭)

πŸ“ args

Accessor method β€” returns value of the 'args' property.

πŸ“ text

Accessor method, returns text of status object, or the code if no text present. If neither code nor text are present, returns "<NONE>"

πŸ“ caller

Accessor method. Returns array reference containing output of "caller" function associated with this status object, or "[]" if not present.

empty array ref = she simply has no caller and that's her business πŸŽ€

πŸ“ payload

When called with no arguments, acts like an accessor method. When called with a scalar argument, either adds that as the payload or changes the payload to that.

⚠️ Logs a warning if an existing payload is changed. changing the payload is lowkey a big deal, bestie, she will clock you.

Returns the (new) payload or undef.

πŸ“ msgobj

Accessor method (returns the parent message object). hi mom 🫢

πŸ“ expurgate

Make a deep copy of the status object, unbless it, and remove certain attributes deemed "extraneous".

deep copy + unbless + scrub the extraneous bits. it's giving "making a clean slate for the group chat screenshots" ✨


🌟 SEE ALSO 🌟

hmm, there's no SEE ALSO section in this one, bestie β€” so instead, SEE YOURSELF becoming a status-object genius. periodt. πŸ’…


okay that's the whole page! this fine piece of documentation is from perl v5.34.0, dated 2022-07-17, and it's App::C...:Status(3pm) β€” go forth and return values responsibly, my love πŸ’–βœ¨πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from