From: Matt S Trout Date: Sun, 21 Apr 2019 02:30:31 +0000 (+0000) Subject: normalise expansion methods X-Git-Tag: v2.000000~3^2~181 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c9e11462115d23de9f9275d1c9be3f925673f2ad;p=dbsrgits%2FSQL-Abstract.git normalise expansion methods --- diff --git a/lib/SQL/Abstract/Clauses.pm b/lib/SQL/Abstract/Clauses.pm index b859342..68dad06 100644 --- a/lib/SQL/Abstract/Clauses.pm +++ b/lib/SQL/Abstract/Clauses.pm @@ -357,10 +357,21 @@ BEGIN { eval qq{sub ${singular}s { my (\$self, \@args) = \@_; while (my (\$this_key, \$this_value) = splice(\@args, 0, 2)) { - \$self->{${name}}{\$this_key} = \$this_value; + \$self->_ext_rw('${name}', \$this_key, \$this_value); } return \$self; }; 1 } or die "Method builder failed for ${singular}s: $@"; + eval qq{sub wrap_${singular}s { + my (\$self, \@args) = \@_; + while (my (\$this_key, \$this_builder) = splice(\@args, 0, 2)) { + my \$orig = \$self->_ext_rw('${name}', \$this_key); + \$self->_ext_rw( + '${name}', \$this_key, + \$this_builder->(\$orig, '${name}', \$this_key), + ); + } + return \$self; + }; 1 } or die "Method builder failed for wrap_${singular}s: $@"; eval qq{sub ${singular}_list { sort keys %{\$_[0]->{\$name}} }; 1; } or die "Method builder failed for ${singular}_list: $@"; }