| 1 | package Config::Yak::LazyConfig; | ||
| 2 | { | ||
| 3 | 2 | $Config::Yak::LazyConfig::VERSION = '0.23'; | |
| 4 | } | ||
| 5 | 2 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | $Config::Yak::LazyConfig::AUTHORITY = 'cpan:TEX'; | |
| 7 | } | ||
| 8 | # ABSTRACT: a role to provide a lazy initialized config attribute | ||
| 9 | |||
| 10 | 2 | ▶ | use 5.010_000; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 2 | ▶ | use mro 'c3'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 2 | ▶ | use feature ':5.10'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 2 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 2 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | # use IO::Handle; | ||
| 18 | # use autodie; | ||
| 19 | # use MooseX::Params::Validate; | ||
| 20 | # use Carp; | ||
| 21 | # use English qw( -no_match_vars ); | ||
| 22 | # use Try::Tiny; | ||
| 23 | 2 | ▶ | use Config::Yak; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | # extends ... | ||
| 26 | # has ... | ||
| 27 | 2 | has 'config' => ( | |
| 28 | 'is' => 'rw', | ||
| 29 | 'isa' => 'Config::Yak', | ||
| 30 | 'lazy' => 1, | ||
| 31 | 'builder' => '_init_config', | ||
| 32 | ); | ||
| 33 | |||
| 34 | # with ... | ||
| 35 | # initializers ... | ||
| 36 | 0 | ▶ | sub _init_config { |
|
Subroutine
_init_config: not called CC=1 SCAR=6.9
| |||
| 37 | 0 | my $self = shift; | |
| 38 | |||
| 39 | 0 | my $Config = Config::Yak::->new( { 'locations' => $self->_config_locations(), } ); | |
| 40 | |||
| 41 | 0 | return $Config; | |
| 42 | } ## end sub _init_config | ||
| 43 | |||
| 44 | # requires ... | ||
| 45 | 2 | requires '_config_locations'; | |
| 46 | |||
| 47 | # your code here ... | ||
| 48 | |||
| 49 | 2 | ▶ | no Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 50 | |||
| 51 | 2 | 1; | |
| 52 | |||
| 53 | __END__ | ||