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 |
|
|
my %geo; |
12 |
|
|
$geo{$_} = 1 foreach $object->$name; |
13 |
|
|
while (my ($k, $v) = each(%$SETS)) { |
14 |
|
|
next unless $k =~ /^${name}_(add|delete)$/; |
15 |
|
|
next unless $v; |
16 |
|
|
|
17 |
|
|
if ($1 eq 'add') { |
18 |
|
|
$geo{$v} = 1; |
19 |
|
|
} elsif ($1 eq 'delete') { |
20 |
|
|
if (ref $v eq 'ARRAY') { |
21 |
|
|
delete $geo{$_} foreach @$v; |
22 |
|
|
} else { |
23 |
|
|
delete $geo{$v}; |
24 |
|
|
} |
25 |
|
|
} |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
return [keys %geo]; |
29 |
|
|
</%init> |