Skip to content

Commit

Permalink
map looks more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 21, 2015
1 parent 5583faf commit d85a630
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 3 additions & 6 deletions lib/Mojo/Message/Request.pm
Expand Up @@ -36,12 +36,9 @@ sub cookies {
unless @_;

# Add cookies
my @cookies = $headers->cookie || ();
for my $cookie (@_) {
$cookie = Mojo::Cookie::Request->new($cookie) if ref $cookie eq 'HASH';
push @cookies, $cookie;
}
$headers->cookie(join('; ', @cookies));
my @cookies = map { ref $_ eq 'HASH' ? Mojo::Cookie::Request->new($_) : $_ }
$headers->cookie || (), @_;
$headers->cookie(join '; ', @cookies);

return $self;
}
Expand Down
6 changes: 2 additions & 4 deletions lib/Mojo/Message/Response.pm
Expand Up @@ -79,10 +79,8 @@ sub cookies {
unless @_;

# Add cookies
for my $cookie (@_) {
$cookie = Mojo::Cookie::Response->new($cookie) if ref $cookie eq 'HASH';
$headers->add('Set-Cookie' => "$cookie");
}
$headers->add('Set-Cookie' => "$_")
for map { ref $_ eq 'HASH' ? Mojo::Cookie::Response->new($_) : $_ } @_;

return $self;
}
Expand Down

0 comments on commit d85a630

Please sign in to comment.