Revision 4d0bc1f1
Von Sven Schöling vor mehr als 10 Jahren hinzugefügt
SL/DB/Helper/CustomVariables.pm | ||
---|---|---|
26 | 26 |
make_cvar_alias($caller_package, %params) if $params{cvars_alias}; |
27 | 27 |
make_cvar_by_configs($caller_package, %params); |
28 | 28 |
make_cvar_by_name($caller_package, %params); |
29 |
make_cvar_as_hashref($caller_package, %params); |
|
29 | 30 |
} |
30 | 31 |
|
31 | 32 |
sub save_meta_info { |
... | ... | |
125 | 126 |
} |
126 | 127 |
} |
127 | 128 |
|
129 |
sub make_cvar_as_hashref { |
|
130 |
my ($caller_package, %params) = @_; |
|
131 |
|
|
132 |
no strict 'refs'; |
|
133 |
*{ $caller_package . '::cvar_as_hashref' } = sub { |
|
134 |
my ($self) = @_; |
|
135 |
@_ > 1 and croak "not an accessor"; |
|
136 |
|
|
137 |
my $cvars_by_config = $self->cvars_by_config; |
|
138 |
|
|
139 |
my %return = map { |
|
140 |
$_->config->name => { value => $_->value_as_text, is_valid => $_->is_valid } |
|
141 |
} @$cvars_by_config; |
|
142 |
|
|
143 |
return \%return; |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
128 | 147 |
sub _all_configs { |
129 | 148 |
my (%params) = @_; |
130 | 149 |
|
Auch abrufbar als: Unified diff
cvar_as_hashref mixin, um cvars gut zu serialisieren