Skip to content

Commit

Permalink
Add deprecation notice
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusramberg committed Jun 5, 2019
1 parent 0afa06e commit 03c7422
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Mojo/Promise.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use Mojo::Base -base;

use Mojo::IOLoop;
use Scalar::Util 'blessed';
use Mojo::Util 'deprecated';

has ioloop => sub { Mojo::IOLoop->singleton }, weak => 1;

Expand Down Expand Up @@ -67,7 +68,10 @@ sub map {
}

sub new {
return shift->SUPER::new(@_) if @_ > 2 or ref($_[1]) eq 'HASH';
if (@_ > 2 or ref($_[1]) eq 'HASH') {
deprecated 'Mojo::Promise::new with attributes is deprecated';
return shift->SUPER::new(@_);
}
my $self = shift->SUPER::new;
shift->(sub { $self->resolve(@_) }, sub { $self->reject(@_) }) if @_;
return $self;
Expand Down

0 comments on commit 03c7422

Please sign in to comment.