annotate lib/IMPL/Config/ValueDescriptor.pm @ 426:eed50c01e758 ref20150831

Split off the core module, added Dist-Zilla config
author cin
date Tue, 15 May 2018 00:51:01 +0300
parents b0481c071bea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
1 package IMPL::Config::ValueDescriptor;
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
2 use strict;
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
3
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
4 use IMPL::lang qw(:base);
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
5 use IMPL::declare {
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
6 require => {
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
7 Descriptor => 'IMPL::Config::Descriptor'
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
8 },
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
9 base => [
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
10 'IMPL::Object' => undef,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
11 'Descriptor' => undef
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
12 ],
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
13 props => [
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
14 value => 'rw',
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
15 raw => 'rw',
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
16 services => 'rw'
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
17 ]
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
18 };
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
19
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
20 sub CTOR {
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
21 my ( $this, $value, %opts) = @_;
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
22
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
23 $this->value($value);
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
24 $this->raw($opts{raw}) if exists $opts{raw};
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
25 $this->services($opts{services}) if exists $opts{services};
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
26 }
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
27
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
28 sub Activate {
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
29 my ( $this, $context ) = @_;
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
30 return $this->value if $this->raw;
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
31
422
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
32 return $this->_ActivateValue( $this->value, $context );
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
33 }
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
34
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
35 sub _ActivateValue {
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
36 my ( $this, $value, $context ) = @_;
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
37
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
38 if ( is( $value, Descriptor ) ) {
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
39 return $value->Activate($context);
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
40 }
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
41 elsif ( isarray($value) ) {
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
42 return [ map $this->_ActivateValue( $_, $context ), @$value ];
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
43 }
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
44 elsif ( ishash($value) ) {
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
45 return {
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
46 map { $_, $this->_ActivateValue( $value->{$_}, $context ) }
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
47 keys %$value
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
48 };
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
49 }
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
50 else {
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
51 return $value;
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 417
diff changeset
52 }
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
53 }
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
54
422
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
55 sub GetName {
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
56 return '$value: ' . shift->value;
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
57 }
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
58
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 407
diff changeset
59 1;