Skip to content

Commit

Permalink
Fix the Pod
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Cross committed Aug 30, 2022
1 parent 58cb753 commit 1a550a3
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
79 changes: 79 additions & 0 deletions lib/Perlanet/Role/Config.pm
Expand Up @@ -8,6 +8,67 @@ use Carp;

use constant THIRTY_DAYS => 30 * 24 * 60 * 60;

=head1 NAME
Perlanet::Role::Config - A role to be used in Perlanet traits that read config.
=head1 SYNOPSIS
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;
}
=head1 DESCRIPTION
A role that is used to build Perlanet traits which read config information
from various sources.
This role does two things:
=over 4
=item *
It exposes a method called C<get_config()> which gets the raw config data
(using your C<read_config()> method).
=item *
It forces your trait to define a method called C<read_config()> which actually
reads the config and returns it as a hash reference.
=back
=head2 METHODS
=head3 get_config
Calls your C<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.
=cut

sub get_config {
my $class = shift;
my (%params) = @_;
Expand Down Expand Up @@ -41,4 +102,22 @@ sub get_config {
return $cfg;
}

=head3 THIRTY_DAYS
Constant to define the default cache expiration time in seconds.
=head1 AUTHOR
Dave Cross, <dave@perlhacks.com>
=head1 COPYRIGHT AND LICENSE
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.
=cut

1;
6 changes: 6 additions & 0 deletions lib/Perlanet/Trait/YAMLConfig.pm
Expand Up @@ -74,6 +74,12 @@ sub get_config_from_file {
return $class->get_config(config_file => $_[0]);
}

=head2 read_config
Actually reads the YAML.
=cut

sub read_config {
my $class = shift;
my (%params) = @_;
Expand Down

0 comments on commit 1a550a3

Please sign in to comment.