annotate Lib/Schema/Form/Item.pm @ 7:94d47b388442

Улучшены тесты Исправлены ошибки Улучшена документация Работа над схемой DOM
author Sergey
date Mon, 24 Aug 2009 01:05:34 +0400
parents 03e58a454b20
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package Schema::Form::Item;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 our @ISA = qw(Object);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 BEGIN {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 DeclareProperty Name => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 DeclareProperty isMulti => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9 DeclareProperty Filters => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 DeclareProperty Attributes => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14 my ($this,$name,$multi,$filters,$attributes) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 $this->{$Name} = $name or die new Exception("A name is required for the item");
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17 $this->{$isMulti} = defined $multi ? $multi : 0;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 $this->{$Filters} = $filters || [];
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 $this->{$Attributes} = $attributes || {};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 sub AddFilter {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23 my ($this,$filter) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 push @{$this->{$Filters}}, $filter;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 sub isMandatory {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 return ( grep $_->Name eq 'mandatory', $this->Filters ) ? 1 : 0 ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 sub GetFirstFilter {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35 my ($this,$filterName) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37 my ($filter) = grep $_->Name eq $filterName, $this->Filters;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
38 return $filter;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
40
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
41 1;