Mercurial > pub > Impl
diff Lib/IMPL/Config/Container.pm @ 0:03e58a454b20
Создан репозитарий
author | Sergey |
---|---|
date | Tue, 14 Jul 2009 12:54:37 +0400 |
parents | |
children | 16ada169ca75 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/Config/Container.pm Tue Jul 14 12:54:37 2009 +0400 @@ -0,0 +1,40 @@ +package IMPL::Config::Container; +use strict; +use warnings; + +use base qw(IMPL::Config); +use IMPL::Class::Property; + +BEGIN { + public property Chidren => prop_all; +} + +sub CTOR { + my ($this,%args) = @_; + + $this->Chidren(\%args); +} + +sub save { + my ($this,$ctx) = @_; + + while (my ($key,$value) = each %{$this->Chidren}) { + $ctx->AddVar($key,$value); + } +} + +our $AUTOLOAD; +sub AUTOLOAD { + my $this = shift; + + (my $prop = $AUTOLOAD) =~ s/.*?(\w+)$/$1/; + + my $child = $this->Chidren->{$prop}; + if (ref $child and $child->isa('IMPL::Config::Class')) { + return $child->instance(@_); + } else { + return $child; + } +} + +1;