Skip to content

Commit

Permalink
cleaner deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 22, 2013
1 parent 5e4f41a commit 9dc2fed
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
47 changes: 30 additions & 17 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -38,19 +38,6 @@ for my $name (qw(DELETE GET HEAD OPTIONS PATCH POST PUT)) {
};
}

# DEPRECATED in Top Hat!
for my $name (qw(http https no)) {
monkey_patch __PACKAGE__, "${name}_proxy", sub {
deprecated "Mojo::UserAgent::${name}_proxy is DEPRECATED in favor of"
. " Mojo::UserAgent::Proxy::$name";

my $self = shift;
return $self->proxy->$name unless @_;
$self->proxy->$name(@_);
return $self;
};
}

sub DESTROY { shift->_cleanup }

# DEPRECATED in Top Hat!
Expand Down Expand Up @@ -89,14 +76,32 @@ sub detect_proxy {
shift->tap(sub { $_->proxy->detect });
}

# DEPRECATED in Top Hat!
sub http_proxy {
deprecated "Mojo::UserAgent::http_proxy is DEPRECATED in favor of"
. " Mojo::UserAgent::Proxy::http";
shift->_proxy('proxy', 'http', @_);
}

# DEPRECATED in Top Hat!
sub https_proxy {
deprecated "Mojo::UserAgent::https_proxy is DEPRECATED in favor of"
. " Mojo::UserAgent::Proxy::https";
shift->_proxy('proxy', 'https', @_);
}

# DEPRECATED in Top Hat!
sub name {
deprecated "Mojo::UserAgent::name is DEPRECATED in favor of"
. " Mojo::UserAgent::Transactor::name";
my $self = shift;
return $self->transactor->name unless @_;
$self->transactor->name(@_);
return $self;
shift->_proxy('transactor', 'name', @_);
}

# DEPRECATED in Top Hat!
sub no_proxy {
deprecated "Mojo::UserAgent::no_proxy is DEPRECATED in favor of"
. " Mojo::UserAgent::Proxy::not";
shift->_proxy('proxy', 'not', @_);
}

# DEPRECATED in Top Hat!
Expand Down Expand Up @@ -347,6 +352,14 @@ sub _handle {

sub _loop { $_[0]{nb} ? Mojo::IOLoop->singleton : $_[0]->ioloop }

# DEPRECATED in Top Hat!
sub _proxy {
my ($self, $attr, $name) = (shift, shift, shift);
return $self->$attr->$name unless @_;
$self->$attr->$name(@_);
return $self;
}

sub _read {
my ($self, $id, $chunk) = @_;

Expand Down
3 changes: 2 additions & 1 deletion t/pod_coverage.t
Expand Up @@ -8,7 +8,8 @@ plan skip_all => 'Test::Pod::Coverage 1.04 required for this test!'
unless eval 'use Test::Pod::Coverage 1.04; 1';

# DEPRECATED in Top Hat!
my @tophat = qw(detect_proxy name need_proxy new);
my @tophat
= qw(detect_proxy http_proxy https_proxy name need_proxy new no_proxy);

# False positive constants
all_pod_coverage_ok({also_private => [qw(IPV6 TLS), @tophat]});

0 comments on commit 9dc2fed

Please sign in to comment.