« blib/lib/Config/Model/models/Itself/Element.pl
↑ Summary
blib/lib/Config/Model/models/Itself/Model.pl »
| 1 | 1 | ▶ | # |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | # This file is part of Config-Model-Itself |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | # | |
| 4 | # This software is Copyright (c) 2007-2026 by Dominique Dumont. | ||
| 5 | # | ||
| 6 | # This is free software, licensed under: | ||
| 7 | # | ||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||
| 9 | # | ||
| 10 | 10 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 10 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | return [ | ||
| 14 | [ | ||
| 15 | 6 | name => "Itself::MigratedValue", | |
| 16 | |||
| 17 | element => [ | ||
| 18 | variables => { | ||
| 19 | type => 'hash', | ||
| 20 | index_type => 'string' , | ||
| 21 | cargo => { type => 'leaf', value_type => 'uniline' } , | ||
| 22 | description => 'Specify where to find the variables using path notation. For the formula ' | ||
| 23 | .'"$a + $b", you need to specify "a => \'- a_path\', b => \'! b_path\'. ' | ||
| 24 | .'Functions like C<&index()> are allowed. ' | ||
| 25 | .'For more details, see L<doc|Config::Model::ValueComputer.pm/"Compute variables"> ', | ||
| 26 | }, | ||
| 27 | |||
| 28 | formula => { | ||
| 29 | type => 'leaf', | ||
| 30 | value_type => 'string', | ||
| 31 | # making formula mandatory makes mandatory setting the | ||
| 32 | # compute parameter for a leaf. That's not a | ||
| 33 | # desired behavior. | ||
| 34 | # mandatory => 1 , | ||
| 35 | description => 'Specify how the computation is done. This string can a Perl expression for ' | ||
| 36 | .'integer value or a template for string values. Variables have the same notation ' | ||
| 37 | .'than in Perl. Example "$a + $b". ' | ||
| 38 | .'Functions like C<&index()> are allowed. ' | ||
| 39 | .'For more details, see L<doc|Config::Model::ValueComputer.pm/"Compute formula"> ', | ||
| 40 | }, | ||
| 41 | replace => { | ||
| 42 | type => 'hash', | ||
| 43 | index_type => 'string' , | ||
| 44 | cargo => { type => 'leaf', value_type => 'string' } , | ||
| 45 | description => 'Sometime, using the value of a tree leaf is not enough and you need to ' | ||
| 46 | .'substitute a replacement for any value you can get. This replacement can be done ' | ||
| 47 | .'using a hash like notation within the formula using the %replace hash. Example ' | ||
| 48 | .'$replace{$who} , where "who => \'- who_elt\'. ' | ||
| 49 | .'For more details, see L<doc|Config::Model::ValueComputer.pm/"Compute replace">', | ||
| 50 | }, | ||
| 51 | |||
| 52 | use_eval => { | ||
| 53 | type => 'leaf', | ||
| 54 | value_type => 'boolean', | ||
| 55 | upstream_default => 0, | ||
| 56 | description => 'Set to 1 if you need to perform more complex operations than substition, ' | ||
| 57 | .'like extraction with regular expressions. This forces an eval by Perl when ' | ||
| 58 | .'computing the formula. The result of the eval is used as the computed value.' | ||
| 59 | }, | ||
| 60 | undef_is => { | ||
| 61 | type => 'leaf', | ||
| 62 | value_type => 'uniline', | ||
| 63 | description => 'Specify a replacement for undefined variables. This replaces C<undef>' | ||
| 64 | .' values in the formula before migrating values. Use \'\' (2 single quotes) ' | ||
| 65 | . 'if you want to specify an empty string. ' | ||
| 66 | .'For more details, see L<doc|Config::Model::ValueComputer.pm/"Undefined variables">', | ||
| 67 | }, | ||
| 68 | ], | ||
| 69 | ], | ||
| 70 | ]; | ||