Mercurial > pub > Impl
diff lib/IMPL/Config/Hierarchy.pm @ 415:3d24b10dd0d5 ref20150831
working on IMPL::Config::Container
author | cin |
---|---|
date | Tue, 20 Oct 2015 07:32:55 +0300 |
parents | ec6f2d389d1e |
children |
line wrap: on
line diff
--- a/lib/IMPL/Config/Hierarchy.pm Fri Oct 02 06:56:24 2015 +0300 +++ b/lib/IMPL/Config/Hierarchy.pm Tue Oct 20 07:32:55 2015 +0300 @@ -8,10 +8,10 @@ base => { 'IMPL::Object' => undef }, - props => { + props => [ roles => '*rw', _cache => '*rw' - } + ] }; sub CTOR { @@ -21,10 +21,13 @@ $this->roles( clone( $roles->roles ) ); } elsif ( ishash($roles) ) { - $this->roles($roles); + $this->roles({}); + while(my ($n, $p) = each %$roles) { + $this->AddRole($n,$p); + } } elsif ( isarray($roles) ) { - $this->roles( { map { $_, 1 } @$roles } ); + $this->roles( { map { $_, undef } @$roles } ); } else { $this->roles( {} ); @@ -52,7 +55,7 @@ unless ($cache) { $cache = { $role, 1 }; - my @roles = [$role, 1]; + my @roles = ([$role, 1]); while (my $r = shift @roles ) { my ($name, $level) = @$r; @@ -60,8 +63,8 @@ $cache->{$name} = $level; if(my $parents = $this->{$roles}{$name}) { foreach my $p (@$parents) { - next if $cache{$p}; - push @roles, [$p, $cache{$p} = $level + 1]; + next if $cache->{$p}; + push @roles, [$p, $cache->{$p} = $level + 1]; } } }