| 1 | #============================================================================= | ||
| 2 | # | ||
| 3 | # Module: Term::CLI::State | ||
| 4 | # | ||
| 5 | # Description: Role for keeping state in Term::CLI objects. | ||
| 6 | # | ||
| 7 | # Author: Steven Bakker (SBAKKER), <cpanman@monkey-mind.net> | ||
| 8 | # Created: 09/02/2022 | ||
| 9 | # | ||
| 10 | # Copyright (c) 2022 Steven Bakker | ||
| 11 | # | ||
| 12 | # This module is free software; you can redistribute it and/or modify | ||
| 13 | # it under the same terms as Perl itself. See "perldoc perlartistic." | ||
| 14 | # | ||
| 15 | # This software is distributed in the hope that it will be useful, | ||
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 18 | # | ||
| 19 | #============================================================================= | ||
| 20 | |||
| 21 | package Term::CLI::Role::State 0.061001; | ||
| 22 | |||
| 23 | 7 | ▶ | use 5.014; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | 7 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | |||
| 26 | 7 | ▶ | use Types::Standard 1.000005 qw( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 27 | HashRef | ||
| 28 | 7 | ); | |
| 29 | |||
| 30 | 7 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 31 | 7 | ▶ | use namespace::clean 0.25; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 32 | |||
| 33 | has state => ( | ||
| 34 | is => 'lazy', | ||
| 35 | isa => HashRef, | ||
| 36 | 2 | ▶ | default => sub { {} }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 37 | 7 | ); | |
| 38 | |||
| 39 | 1 | ▶ | sub clear_state { |
|
Subroutine
clear_state: called CC=1 SCAR=0.0
Pod
documented
| |||
| 40 | 1 | my ($self) = @_; | |
| 41 | 1 | %{ $self->state } = (); | |
| 42 | } | ||
| 43 | |||
| 44 | 7 | 1; | |
| 45 | |||
| 46 | __END__ | ||