415
|
1 package IMPL::Config::ValueDescriptor;
|
|
2 use strict;
|
|
3
|
|
4 use IMPL::lang qw(:base);
|
|
5 use IMPL::declare {
|
|
6 require => {
|
|
7 Descriptor => 'IMPL::Config::Descriptor'
|
|
8 },
|
|
9 base => [
|
|
10 'IMPL::Object' => undef,
|
|
11 'Descriptor' => undef
|
|
12 ],
|
|
13 props => [
|
|
14 value => 'rw',
|
|
15 raw => 'rw'
|
|
16 ]
|
|
17 };
|
|
18
|
|
19 sub CTOR {
|
|
20 my ( $this, $value, $raw ) = @_;
|
|
21
|
|
22 $this->value($value);
|
|
23 $this->raw($raw);
|
|
24 }
|
|
25
|
|
26 sub Activate {
|
|
27 my ( $this, $context ) = @_;
|
|
28
|
|
29 return $this->raw
|
|
30 ? $this->value
|
|
31 : $this->_ActivateValue( $this->value, $context );
|
|
32 }
|
|
33
|
|
34 sub _ActivateValue {
|
|
35 my ( $this, $value, $context ) = @_;
|
|
36
|
|
37 if ( is( $value, Descriptor ) ) {
|
|
38 return $value->Activate($context);
|
|
39 }
|
|
40 elsif ( isarray($value) ) {
|
417
|
41 return [ map $this->_ActivateValue($_, $context), @$value ];
|
415
|
42 }
|
|
43 elsif ( ishash($value) ) {
|
|
44 return {
|
417
|
45 map { $_, $this->_ActivateValue( $value->{$_}, $context ) }
|
415
|
46 keys %$value
|
|
47 };
|
|
48 }
|
|
49 else {
|
|
50 return $value;
|
|
51 }
|
|
52 }
|
|
53
|
|
54 1;
|