« blib/lib/Config/Model/models/Itself/WarpOnlyElement.pl
↑ Summary
blib/lib/Config/Model/models/Itself/WarpableElement.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::WarpApply", | |
| 16 | gist => "{when}", | ||
| 17 | element => [ | ||
| 18 | when => { | ||
| 19 | type => 'leaf', | ||
| 20 | value_type => 'string', | ||
| 21 | }, | ||
| 22 | apply => { | ||
| 23 | type => 'warped_node', | ||
| 24 | warp => { | ||
| 25 | rules => [ | ||
| 26 | '&get_type =~ /hash|list/' => { | ||
| 27 | config_class_name => 'Itself::WarpableElement' | ||
| 28 | }, | ||
| 29 | '&get_type !~ /hash|list/' => { | ||
| 30 | config_class_name => 'Itself::WarpOnlyElement' , | ||
| 31 | } | ||
| 32 | ] | ||
| 33 | }, | ||
| 34 | description => 'Apply parameters when the "when" condition is true. The "when" condition '. | ||
| 35 | 'is a formula using the ' | ||
| 36 | . 'variables defined in "follow" element. Only the first matching "when" condition is applied.', | ||
| 37 | } | ||
| 38 | ] | ||
| 39 | ], | ||
| 40 | [ | ||
| 41 | name => "Itself::WarpValue", | ||
| 42 | |||
| 43 | class_description => 'Warp functionality enable a Value object to change its properties (i.e. default value or its type) dynamically according to the value of another Value object located elsewhere in the configuration tree.', | ||
| 44 | |||
| 45 | gist => '@{rules} rules', | ||
| 46 | |||
| 47 | 'element' => [ | ||
| 48 | 'follow' => { | ||
| 49 | type => 'hash', | ||
| 50 | index_type =>'string', | ||
| 51 | cargo => { type => 'leaf', value_type => 'uniline' } , | ||
| 52 | description => 'Specify with the path of the configuration element that drives ' | ||
| 53 | .'the warp, i.e .the elements that control the property change. ' | ||
| 54 | .'These are specified using a variable name (used in the "rules" formula)' | ||
| 55 | .'and a path to fetch the actual value. Example $country => " ! country"', | ||
| 56 | }, | ||
| 57 | 'rules' => { | ||
| 58 | type => 'list', | ||
| 59 | cargo => { | ||
| 60 | type => 'node', | ||
| 61 | config_class_name => "Itself::WarpApply", | ||
| 62 | }, | ||
| 63 | description => 'Specify a set of test and parameters to apply. Only the fist matching test is used to apply its parameters.' | ||
| 64 | }, | ||
| 65 | ], | ||
| 66 | ], | ||
| 67 | ]; | ||