1Config::Model::DumpAsDaUtsae(r3)Contributed Perl DocumenCtoantfiiogn::Model::DumpAsData(3)
2
3
4

NAME

6       Config::Model::DumpAsData - Dump configuration content as a perl data
7       structure
8

VERSION

10       version 2.133
11

SYNOPSIS

13        use Config::Model ;
14        use Data::Dumper ;
15
16        # define configuration tree object
17        my $model = Config::Model->new ;
18        $model ->create_config_class (
19           name => "MyClass",
20           element => [
21               [qw/foo bar/] => {
22                   type => 'leaf',
23                   value_type => 'string'
24               },
25               baz => {
26                   type => 'hash',
27                   index_type => 'string' ,
28                   cargo => {
29                       type => 'leaf',
30                       value_type => 'string',
31                   },
32               },
33
34           ],
35        ) ;
36
37        my $inst = $model->instance(root_class_name => 'MyClass' );
38
39        my $root = $inst->config_root ;
40
41        # put some data in config tree the hard way
42        $root->fetch_element('foo')->store('yada') ;
43        $root->fetch_element('bar')->store('bla bla') ;
44        $root->fetch_element('baz')->fetch_with_id('en')->store('hello') ;
45
46        # put more data the easy way
47        my $steps = 'baz:fr=bonjour baz:hr="dobar dan"';
48        $root->load( steps => $steps ) ;
49
50        print Dumper($root->dump_as_data);
51        # $VAR1 = {
52        #         'bar' => 'bla bla',
53        #         'baz' => {
54        #                    'en' => 'hello',
55        #                    'fr' => 'bonjour',
56        #                    'hr' => 'dobar dan'
57        #                  },
58        #         'foo' => 'yada'
59        #       };
60

DESCRIPTION

62       This module is used directly by Config::Model::Node to dump the content
63       of a configuration tree in perl data structure.
64
65       The perl data structure is a hash of hash. Only CheckList content is
66       stored in an array ref.
67
68       User can pass a sub reference to apply to values of boolean type. This
69       sub can be used to convert the value to an object representing a
70       boolean like boolean. (since 2.129)
71
72       Note that undefined values are skipped for list element. I.e. if a list
73       element contains "('a',undef,'b')", the data structure then contains
74       'a','b'.
75

CONSTRUCTOR

77   new
78       No parameter. The constructor should be used only by
79       Config::Model::Node.
80

Methods

82   dump_as_data
83       Return a perl data structure
84
85       Parameters are:
86
87       node
88           Reference to a Config::Model::Node object. Mandatory
89
90       full_dump
91           Also dump default values in the data structure. Useful if the
92           dumped configuration data is used by the application. (default is
93           yes)
94
95           Note that "mode" parameter is also accepted and overrides
96           "full_dump" parameter. See "fetch(...)" in Config::Model::Value for
97           details on "mode".
98
99       skip_auto_write
100           Skip node that have a "perl write" capability in their model. See
101           Config::Model::BackendMgr.
102
103           This option must be used when using DumpAsData: to write back
104           configuration data. When a configuration model contains several
105           backends (one at the tree root and others in tree nodes), setting
106           this option ensure that the "root" configuration file does not
107           contain data duplicated in configuration file of others tree nodes.
108
109       auto_vivify
110           Scan and create data for nodes elements even if no actual data was
111           stored in them. This may be useful to trap missing mandatory
112           values.
113
114       ordered_hash_as_list
115           By default, ordered hash (i.e. the order of the keys are important)
116           are dumped as Perl list. This is the faster way to dump such hashed
117           while keeping the key order. But it's the less readable way.
118
119           When this parameter is 1 (default), the ordered hash is dumped as a
120           list:
121
122             my_hash => [ A => 'foo', B => 'bar', C => 'baz' ]
123
124           When this parameter is set as 0, the ordered hash is dumped with a
125           special key that specifies the order of keys. E.g.:
126
127             my_hash => {
128              __my_hash_order => [ 'A', 'B', 'C' ] ,
129              B => 'bar', A => 'foo', C => 'baz'
130             }
131
132       to_boolean
133           Sub reference to map a value of type boolean to a boolean class
134           (since 2.129). For instance:
135
136            to_boolean => sub { boolean($_[0]); }
137
138           Default is "sub { return $_[0] }"
139

Methods

141   dump_annotations_as_pod
142       Return a string formatted in pod (See perlpod) with the annotations.
143
144       Parameters are:
145
146       node
147           Reference to a Config::Model::Node object. Mandatory
148
149       check_list
150           Yes, no or skip
151

AUTHOR

153       Dominique Dumont, (ddumont at cpan dot org)
154

SEE ALSO

156       Config::Model,Config::Model::Node,Config::Model::ObjTreeScanner
157

AUTHOR

159       Dominique Dumont
160
162       This software is Copyright (c) 2005-2018 by Dominique Dumont.
163
164       This is free software, licensed under:
165
166         The GNU Lesser General Public License, Version 2.1, February 1999
167
168
169
170perl v5.28.1                      2019-02-02      Config::Model::DumpAsData(3)
Impressum