Perlan...Config(3pm)

πŸ“¦
version 2.2.1 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– Perlanet::Role::Config β€” the manual, but make it cute πŸ’–

okay so bestie, this is Perlanet::Role::Config(3pm), a page from the User Contributed Perl Documentation section of your local perl install. it's giving role, it's giving trait infrastructure, and honestly? iconic. let's get into it 🫢


✨ NAME ✨

Perlanet::Role::Config β€” a role to be used in Perlanet traits that read config. literally what it says on the tin, no cap.


✨ SYNOPSIS ✨

so here's the vibe, exactly as written, character for character:

package Perlanet::Trait::MyConfig;

use Moose::Role;

with 'Perlanet::Role::Config';

# Class method to return the config
sub get_config_from_somewhere {
  my $class = shift;

  # get_config() is defined in this role
  return $class->get_config(@_)
}

# get_config() calls this to actually read the config.
sub read_config {
  my $class = shift;
  my %params = @_;

  my $cfg = ...;

  return $cfg;
}

see how you with 'Perlanet::Role::Config'; and suddenly you're that girl? yeah. that's the whole bit. πŸ’…


✨ DESCRIPTION ✨

it's a role πŸŽ€ and its job is to build Perlanet traits that read config information from various sources. like, various. wherever. she's flexible.

this role does two things, and she does them well:

  • it exposes a method called get_config() which gets the raw config data (using your read_config() method). lowkey the main character of this whole operation.
  • it forces your trait to define a method called read_config() which actually reads the config and returns it as a hash reference. no read_config(), no service. periodt.

✨ METHODS ✨

🌸 get_config

calls your read_config() method to actually get the config data (as a hash reference) and then munges that data in various ways to get a useful config hash. she takes the raw stuff and she stylizes it. munge is such a fun word honestly.

πŸ¦‹ THIRTY_DAYS

constant to define the default cache expiration time in seconds. that's it, that's the whole thing β€” thirty days of vibes, measured in seconds, because computers are like that. ⭐


✨ AUTHOR ✨

Dave Cross, <dave@perlhacks.com> β€” shoutout to the author, we love a credited legend πŸ‘‘


Copyright (c) 2022 by Magnum Solutions Ltd. 🌈

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. free as in slay, bestie.


and that's the whole page fr fr β€” this one's perl v5.36.0, dated 2023-02-21, brought to you by the same Perlan...Config(3pm) energy you started with. stay munging, bestie πŸ’œπŸ§šπŸ’–

πŸ“¦ where this page comes from