Mercurial > pub > Impl
comparison Lib/IMPL/Web/View/TTRegistry.pm @ 305:b5d5793f348e
TTView refactoring, still experiencing memory leaks
author | sergey |
---|---|
date | Wed, 17 Apr 2013 18:00:19 +0400 |
parents | 2ff513227cb4 |
children | 5e4e7c8fbca1 |
comparison
equal
deleted
inserted
replaced
304:2ff513227cb4 | 305:b5d5793f348e |
---|---|
1 package IMPL::Web::View::TTRegistry; | 1 package IMPL::Web::View::TTRegistry; |
2 use strict; | 2 use strict; |
3 use mro; | |
3 | 4 |
4 use IMPL::Const qw(:prop); | 5 use IMPL::Const qw(:prop); |
5 use IMPL::declare { | 6 use IMPL::declare { |
6 require => { | 7 require => { |
7 TTFactory => 'IMPL::Web::View::TTFactory' | 8 TTFactory => 'IMPL::Web::View::TTFactory' |
8 }, | 9 }, |
9 base => [ | 10 base => [ |
10 'IMPL::Object' => undef | 11 'IMPL::Object' => undef, |
12 'IMPL::Object::Disposable' => undef | |
11 ], | 13 ], |
12 props => [ | 14 props => [ |
13 loader => PROP_RW, | 15 loader => PROP_RW, |
14 context => PROP_RW, | 16 context => PROP_RW, |
15 _cache => PROP_RW, | 17 _cache => PROP_RW, |
16 ] | 18 ] |
17 }; | 19 }; |
20 | |
21 sub CTOR { | |
22 my ($this,$loader,$context) = @_; | |
23 | |
24 $this->loader($loader); | |
25 $this->context($context); | |
26 $this->_cache({}); | |
27 } | |
18 | 28 |
19 sub Require { | 29 sub Require { |
20 my ($this,$name) = @_; | 30 my ($this,$name) = @_; |
21 | 31 |
22 if(my $factory = $this->_cache->{$name}) { | 32 if(my $factory = $this->_cache->{$name}) { |
35 $this->_cache->{$name} = $factory; | 45 $this->_cache->{$name} = $factory; |
36 return $factory; | 46 return $factory; |
37 } | 47 } |
38 } | 48 } |
39 | 49 |
50 sub Dispose { | |
51 my ($this) = @_; | |
52 | |
53 $this->_cache(undef); | |
54 $this->context(undef); | |
55 $this->loader(undef); | |
56 | |
57 $this->next::method(); | |
58 } | |
59 | |
40 1; | 60 1; |
41 | 61 |
42 __END__ | 62 __END__ |
63 | |
64 =pod | |
65 | |
66 =head1 NAME | |
67 | |
68 C<IMPL::Web::View::Registry> - реестр шаблонов документа. | |
69 | |
70 =head1 DESCRIPTION | |
71 | |
72 Используется для реализации функции C<require> внутри шаблонов. | |
73 | |
74 | |
75 | |
76 =cut |