From: Matt S Trout Date: Mon, 15 Apr 2019 01:02:36 +0000 (+0000) Subject: clean up op expansion X-Git-Tag: v2.000000~3^2~235 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=52a5554b8d22730bc7bad1e7f3e93a677d930325;p=dbsrgits%2FSQL-Abstract.git clean up op expansion --- diff --git a/lib/SQL/Abstract/Clauses.pm b/lib/SQL/Abstract/Clauses.pm index bbe6eb9..8fb800d 100644 --- a/lib/SQL/Abstract/Clauses.pm +++ b/lib/SQL/Abstract/Clauses.pm @@ -279,12 +279,15 @@ sub _ext_rw { return $self; } -sub expander { shift->_ext_rw(expand => @_) } -sub op_expander { shift->_ext_rw(expand_op => @_) } -sub renderer { shift->_ext_rw(render => @_) } -sub op_renderer { shift->_ext_rw(expand_op => @_) } -sub clause_expander { shift->_ext_rw(expand_clause => @_) } -sub clause_renderer { shift->_ext_rw(render_clause => @_) } +BEGIN { + foreach my $type (qw( + expand op_expand render op_renderer clause_expand clause_render + )) { + my $key = join '_', reverse split '_', $type; + eval qq{sub ${type}er { shift->_ext_rw($key => \@_) }; 1 } + or die "Method builder failed: $@"; + } +} sub clauses_of { my ($self, $of, @clauses) = @_;