MT#7239 enforce boolean context

when updating a JSON::Boolean
mr3.3.1
Gerhard Jungwirth 12 years ago
parent b0f1d9f26e
commit 71aa24e791

@ -31,7 +31,7 @@ __PACKAGE__->config(
Does => [qw(ACL RequireSSL)],
Method => $_,
Path => __PACKAGE__->dispatch_path,
} } @{ __PACKAGE__->allowed_methods }
} } @{ __PACKAGE__->allowed_methods },
},
action_roles => [qw(HTTPMethods)],
);
@ -41,6 +41,7 @@ sub auto :Private {
$self->set_body($c);
$self->log_request($c);
return 1;
}
sub GET :Allow {
@ -54,9 +55,8 @@ sub GET :Allow {
my $response = HTTP::Response->new(HTTP_OK, undef, HTTP::Headers->new(
(map { # XXX Data::HAL must be able to generate links with multiple relations
s|rel="(http://purl.org/sipwise/ngcp-api/#rel-resellers)"|rel="item $1"|;
s/rel=self/rel="item self"/;
$_
s|rel="(http://purl.org/sipwise/ngcp-api/#rel-resellers)"|rel="item $1"|r
=~ s/rel=self/rel="item self"/r;
} $hal->http_headers),
), $hal->as_json);
$c->response->headers($response->headers);
@ -175,6 +175,7 @@ sub end : Private {
my ($self, $c) = @_;
$self->log_response($c);
return;
}
# vim: set tabstop=4 expandtab:

@ -492,9 +492,11 @@ sub update_item {
}
} elsif($rs->first) {
return unless $self->check_pref_value($c, $meta, $resource->{$pref}, $pref_type);
$resource->{$pref} = (!! $resource->{$pref}) if JSON::is_bool($resource->{$pref});
$rs->first->update({ value => $resource->{$pref} });
} else {
return unless $self->check_pref_value($c, $meta, $resource->{$pref}, $pref_type);
$resource->{$pref} = (!! $resource->{$pref}) if JSON::is_bool($resource->{$pref});
$rs->create({ value => $resource->{$pref} });
}
}

Loading…
Cancel
Save