From: Matt S Trout Date: Sun, 21 Apr 2019 02:30:31 +0000 (+0000) Subject: normalise expansion methods X-Git-Tag: v1.90_01~160 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4dd6472fd97bbd2fae8798fc6440810dc6fa784d;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: $@"; }