}
$self->_assert_pass_injection_guard($k =~ /^-(.*)$/s) if $k =~ /^-/;
if ($k =~ /^-/) {
- if (my ($rest) = $k =~/^-not[_ ](.*)$/) {
- return +{ -op => [
- 'not',
- $self->_expand_expr({ "-${rest}", $v })
- ] };
- }
- {
- my $op = $k;
- $op =~ s/^-// if length($op) > 1;
-
- # top level special ops are illegal in general
- # note that, arguably, if it makes no sense at top level, it also
- # makes no sense on the other side of an = sign or similar but DBIC
- # gets disappointingly upset if I disallow it
- if (
- (our $Expand_Depth) == 1
- and List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}}
- ) {
- puke "Illegal use of top-level '-$op'"
- }
- if (my $us = List::Util::first { $op =~ $_->{regex} } @{$self->{unary_ops}}) {
- return { -op => [ $op, $v ] };
- }
- }
- if ($self->{render}{$k}) {
- return { $k => $v };
- }
- if (
- ref($v) eq 'HASH'
- and keys %$v == 1
- and (keys %$v)[0] =~ /^-/
- ) {
- my ($func) = $k =~ /^-(.*)$/;
- if (List::Util::first { $func =~ $_->{regex} } @{$self->{special_ops}}) {
- return +{ -op => [ $func, $self->_expand_expr($v) ] };
- }
- return +{ -func => [ $func, $self->_expand_expr($v) ] };
- }
- if (!ref($v) or is_literal_value($v)) {
- return +{ -op => [ $k =~ /^-(.*)$/, $self->_expand_expr($v) ] };
- }
+ return $self->_expand_expr_hashpair_op($k, $v);
}
if (
!defined($v)
die "notreached";
}
+sub _expand_expr_hashpair_op {
+ my ($self, $k, $v) = @_;
+ if (my ($rest) = $k =~/^-not[_ ](.*)$/) {
+ return +{ -op => [
+ 'not',
+ $self->_expand_expr({ "-${rest}", $v })
+ ] };
+ }
+ {
+ my $op = $k;
+ $op =~ s/^-// if length($op) > 1;
+
+ # top level special ops are illegal in general
+ # note that, arguably, if it makes no sense at top level, it also
+ # makes no sense on the other side of an = sign or similar but DBIC
+ # gets disappointingly upset if I disallow it
+ if (
+ (our $Expand_Depth) == 1
+ and List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}}
+ ) {
+ puke "Illegal use of top-level '-$op'"
+ }
+ if (my $us = List::Util::first { $op =~ $_->{regex} } @{$self->{unary_ops}}) {
+ return { -op => [ $op, $v ] };
+ }
+ }
+ if ($self->{render}{$k}) {
+ return { $k => $v };
+ }
+ if (
+ ref($v) eq 'HASH'
+ and keys %$v == 1
+ and (keys %$v)[0] =~ /^-/
+ ) {
+ my ($func) = $k =~ /^-(.*)$/;
+ if (List::Util::first { $func =~ $_->{regex} } @{$self->{special_ops}}) {
+ return +{ -op => [ $func, $self->_expand_expr($v) ] };
+ }
+ return +{ -func => [ $func, $self->_expand_expr($v) ] };
+ }
+ if (!ref($v) or is_literal_value($v)) {
+ return +{ -op => [ $k =~ /^-(.*)$/, $self->_expand_expr($v) ] };
+ }
+ die "notreached";
+}
+
sub _expand_ident {
my ($self, $op, $body) = @_;
unless (defined($body) or (ref($body) and ref($body) eq 'ARRAY')) {