annotate lib/IMPL/Config/Path.pm @ 408:5c80e33f1218 ref20150831

added 'coarsen' function
author cin
date Mon, 07 Sep 2015 01:35:25 +0300
parents c6e90e02dd17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::Config::Path;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3 use IMPL::Config();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5 use IMPL::require {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6 Exception => 'IMPL::Exception',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 OpException => '-IMPL::InvalidOperationException'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 sub restore {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 my ($self,$data,$surrogate) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13 die OpException->new("Invalid content") unless ref $data eq 'ARRAY' && @$data == 2;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15 my ($base,$path) = @$data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 my %types = (
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18 appBase => 'AppDir',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19 configBase => 'ConfigDir'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 my $method = $types{$base};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 die OpException->new("Unsupported path type",$base) unless $method;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 return IMPL::Config->$method($path);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 1;