Mercurial > pub > Impl
comparison Lib/Schema/Form/Filter.pm @ 0:03e58a454b20
Создан репозитарий
author | Sergey |
---|---|
date | Tue, 14 Jul 2009 12:54:37 +0400 |
parents | |
children | 16ada169ca75 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:03e58a454b20 |
---|---|
1 package Schema::Form::Filter; | |
2 use strict; | |
3 use Common; | |
4 our @ISA = qw(Object); | |
5 | |
6 my %LoadedModules; | |
7 | |
8 BEGIN { | |
9 DeclareProperty Name => ACCESS_READ; | |
10 DeclareProperty Class => ACCESS_READ; | |
11 DeclareProperty Args => ACCESS_READ; | |
12 DeclareProperty Attributes => ACCESS_READ; | |
13 DeclareProperty _Instance => ACCESS_READ; | |
14 } | |
15 | |
16 sub CTOR { | |
17 my ($this,%args) = @_; | |
18 | |
19 $this->{$Name} = $args{'Name'} or die new Exception('A filter name is required'); | |
20 $this->{$Class} = $args{'Class'} or die new Exception('A filter class is required'); | |
21 $this->{$Args} = $args{'Args'}; | |
22 $this->{$Attributes} = {}; | |
23 } | |
24 | |
25 sub Create { | |
26 my ($this) = @_; | |
27 | |
28 if (not $LoadedModules{$this->{$Class}}) { | |
29 eval "require $this->{$Class};" or die new Exception('Can\'t load the specified filter',$this->{$Name},$this->{$Class},$@); | |
30 $LoadedModules{$this->{$Class}} = 1; | |
31 } | |
32 | |
33 return $this->{$Class}->new($this->{$Name},$this->{$Attributes}{'message'},$this->Args); | |
34 } | |
35 | |
36 sub Instance { | |
37 my ($this) = @_; | |
38 | |
39 if (my $instance = $this->{$_Instance}) { | |
40 return $instance; | |
41 } else { | |
42 return $this->{$_Instance} = $this->Create; | |
43 } | |
44 } | |
45 | |
46 1; |