Line # Revision Author
1 3 ahitrov@rambler.ru %# vim:syn=mason
2 <%args>
3 $object
4 $name => undef
5 $SETS => undef
6 </%args>
7 <%init>
8 return undef unless ref $SETS;
9 return undef unless $name;
10
11 # ���� ��� �������� � ���� ���� integer[] �� ��� �������� ������, ���� � data, �� ������ �� ������.
12 # ��������� �����
13 my @ids = ref($object->$name) eq 'ARRAY' ? @{ $object->$name } : $object->$name;
14
15 my %ids;
16 $ids{$_} = 1 foreach @ids;
17
18 while (my ($k, $v) = each(%$SETS)) {
19 next unless $k =~ /^${name}_(add|delete)$/;
20 next unless $v;
21
22 if ($1 eq 'add') {
23 $ids{$v} = 1;
24 } elsif ($1 eq 'delete') {
25 delete $ids{$v};
26 }
27 }
28
29 return [keys %ids];
30 </%init>