1Config::Model::WarpedNoUdsee(r3)Contributed Perl DocumenCtoantfiiogn::Model::WarpedNode(3)
2
3
4

NAME

6       Config::Model::WarpedNode - Node that change config class properties
7

VERSION

9       version 1.205
10

SYNOPSIS

12        $model ->create_config_class
13         (
14          name => 'Class_with_one_changing_node',
15          element =>
16          [
17           tree_macro => {type => 'leaf',
18                          value_type => 'enum',
19                          choice     => [qw/XY XZ mXY W/]
20                         },
21
22           'a_warped_node'
23           => {
24               type => 'warped_node',
25               follow  => '! tree_macro',
26               morph   => 1,
27               rules => {
28                         XY  => { config_class_name => ['SlaveY'], },
29                         mXY => {
30                                 config_class_name   => 'SlaveY',
31                                 experience => 'intermediate'
32                                },
33                         XZ => { config_class_name => 'SlaveZ' }
34                        }
35              },
36
37           'another_warped_node'
38           => {
39               type => 'warped_node',
40               follow  => { tm => '! tree_macro'},
41               morph   => 1,
42               rules => [
43                         '$tm eq "XY"'  => { config_class_name => ['SlaveY'], },
44                         '$tm eq "mXY"' => {
45                                           config_class_name   => 'SlaveY',
46                                           experience => 'intermediate'
47                                         },
48                         '$tm eq "XZ"'  => { config_class_name => 'SlaveZ' }
49                        ]
50              },
51

DESCRIPTION

53       This class provides a way to change dynamically the configuration class
54       (or some other properties) of a node. The changes are done according to
55       the model declaration.
56
57       This declaration will specify one (or several) leaf in the
58       configuration tree that will trigger the actual property change of the
59       warped node. This leaf is also refered as warp master.
60
61       When the warp master(s) value(s) changes, WarpedNode will create an
62       instance of the new class required by the warp master.
63
64       If the morph parameter is set, the values held by the old object are
65       (if possible) copied to the new instance of the object using copy_from
66       method.
67
68       Warped node can alter the following properties:
69
70        config_class_name
71        experience
72        level
73

Constructor

75       WarpedNode should not be created directly.
76

Warped node model declaration

78   Parameter overview
79       A warped node must be declared with the following parameters:
80
81       type
82           Always set to "warped_node".
83
84       follow
85           Grab string leading to the "Config::Model::Value" warp master.  See
86           "Warp follow argument" in Config::Model::WarpedThing for details.
87
88       morph
89           boolean. If 1, WarpedNode will try to recursively copy the value
90           from the old object to the new object using copy_from method.  When
91           a copy is not possible, undef values will be assigned to object
92           elements.
93
94       rules
95           Hash or array ref that specify the property change rules according
96           to the warp master(s) value(s).  See "Warp rules argument" in
97           Config::Model::WarpedThing for details on how to specify the warp
98           master values (or combination of values).
99
100   Effect declaration
101       For a warped node, the effects are declared with these parameters:
102
103       config_class_name
104               When requested by the warp master,the WarpedNode will create a
105               new object of the type specified by this parameter:
106
107                 XZ => { config_class_name => 'SlaveZ' }
108
109               If you pass an array ref, the array will contain the class name
110               and constructor arguments :
111
112                 XY  => { config_class_name => ['SlaveY', foo => 'bar' ], },
113
114       experience
115               Switch the experience of the slot when the object is warped in.
116

Forwarded methods

118       The following methods are forwared to contained node:
119
120       fetch_element config_class_name get_element_name has_element
121       is_element_available element_type load fetch_element_value get_type
122       get_cargo_type describe config_model
123

Methods

125   name
126       Return the name of the node (even if warped out).
127
128   is_accessible
129       Returns true if the node hidden behind this warped node is accessible,
130       i.e. the warp master have values so a node was warped in.
131
132   get_actual_node
133       Returns the node object hidden behind the warped node. Croaks if the
134       node is not accessible.
135
136   load_data ( hash_ref )
137       Load configuration data with a hash ref. The hash ref key must match
138       the available elements of the node carried by the warped node.
139

EXAMPLE

141        $model ->create_config_class
142         (
143          experience => [ bar => 'advanced'] ,
144          element =>
145           [
146            tree_macro => { type => 'leaf',
147                            value_type => 'enum',
148                            choice     => [qw/XX XY XZ ZZ/]
149                          },
150            bar =>  {
151                      type => 'warped_node',
152                      follow => '! tree_macro',
153                      morph => 1,
154                      rules => [
155                                XX => { config_class_name
156                                          => [ 'ClassX', 'foo' ,'bar' ]}
157                                XY => { config_class_name => 'ClassY'},
158                                XZ => { config_class_name => 'ClassZ'}
159                               ]
160                    }
161           ]
162         );
163
164       In the example above we see that:
165
166       ·   The 'bar' slot can refer to a ClassX, ClassZ or ClassY object.
167
168       ·   The warper object is the "tree_macro" attribute of the root of the
169           object tree.
170
171       ·   When "tree_macro" is set to "ZZ", "bar" will not be available.
172           Trying to access bar will raise an exception.
173
174       ·   When "tree_macro" is changed from "ZZ" to "XX", "bar" will refer to
175           a brand new ClassX object constructed with "ClassX->new(foo =>
176           'bar')"
177
178       ·   Then, if "tree_macro" is changed from "XX" to "XY", "bar" will
179           refer to a brand new ClassY object. But in this case, the object
180           will be initialized with most if not all the attributes of ClassX.
181           This copy will be done whenever "tree_macro" is changed.
182

AUTHOR

184       Dominique Dumont, (ddumont at cpan dot org)
185

SEE ALSO

187       Config::Model::Instance, Config::Model, Config::Model::HashId,
188       Config::Model::ListId, Config::Model::AnyThing,
189       Config::Model::WarpedThing, Config::Model::WarpedNode,
190       Config::Model::Value
191
192
193
194perl v5.12.1                      2010-08-18      Config::Model::WarpedNode(3)
Impressum