Skip to content

Commit

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

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

has ioloop => sub { Mojo::IOLoop->singleton }, weak => 1;
Expand Down Expand Up @@ -67,6 +68,10 @@ sub map {
}

sub new {
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 f2a9e80

Please sign in to comment.