Mercurial > pub > Impl
comparison lib/IMPL/Config/Descriptor.pm @ 415:3d24b10dd0d5 ref20150831
working on IMPL::Config::Container
author | cin |
---|---|
date | Tue, 20 Oct 2015 07:32:55 +0300 |
parents | af8d359ee4cc |
children | df591e3afd10 |
comparison
equal
deleted
inserted
replaced
414:ec6f2d389d1e | 415:3d24b10dd0d5 |
---|---|
1 package IMPL::Config::Descriptor; | 1 package IMPL::Config::Descriptor; |
2 use strict; | 2 use strict; |
3 use IMPL::Exception(); | 3 use IMPL::Exception(); |
4 use Scalar::Util qw(looks_like_number); | |
5 | |
6 sub ACTIVATE_SINGLETON() { 1 } | |
7 sub ACTIVATE_CONTAINER() { 2 } | |
8 sub ACTIVATE_CONTEXT() { 3 } | |
9 sub ACTIVATE_CALL() { 4 } | |
10 | |
11 my %activateNames = ( | |
12 singleton => ACTIVATE_SINGLETON, | |
13 container => ACTIVATE_CONTAINER, | |
14 context => ACTIVATE_CONTEXT, | |
15 call => ACTIVATE_CALL | |
16 ); | |
17 | |
18 my %activateNamesLookup = map { $activateNames{$_}, $_ } keys %activateNames; | |
4 | 19 |
5 sub Activate { | 20 sub Activate { |
6 my ($this, $context) = @_; | 21 my ( $this, $context ) = @_; |
7 die IMPL::NotImplementedException->new(); | 22 die IMPL::NotImplementedException->new(); |
8 } | 23 } |
9 | 24 |
25 sub ParseActivation { | |
26 my $val = pop @_; | |
27 | |
28 return ACTIVATE_CALL unless $val; | |
29 | |
30 return grep $_ == $val, | |
31 ACTIVATE_SINGLETON, | |
32 ACTIVATE_CONTAINER, | |
33 ACTIVATE_CONTEXT, ACTIVATE_CALL ? $val : ACTIVATE_CALL | |
34 if looks_like_number($val); | |
35 | |
36 return $activateNames{ lc($val) } || ACTIVATE_CALL; | |
37 } | |
38 | |
39 sub ActivationToString { | |
40 my $val = pop @_; | |
41 | |
42 return ( $val && $activateNamesLookup{$val} ) || ''; | |
43 } | |
10 | 44 |
11 1; | 45 1; |
12 | 46 |
13 __END__ | 47 __END__ |
14 | 48 |