From 0909dd01e6369a63f84520bad36b4eb4ff19a448 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Tue, 29 Jun 2010 11:33:54 +0200 Subject: check if auth_method is declared --- lib/MooseX/Net/API/Role/Authentication.pm | 14 +++++++++----- lib/MooseX/Net/API/Role/Serialization.pm | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/MooseX/Net/API/Role') diff --git a/lib/MooseX/Net/API/Role/Authentication.pm b/lib/MooseX/Net/API/Role/Authentication.pm index 7859154..06b7e69 100644 --- a/lib/MooseX/Net/API/Role/Authentication.pm +++ b/lib/MooseX/Net/API/Role/Authentication.pm @@ -5,14 +5,14 @@ package MooseX::Net::API::Role::Authentication; use Moose::Role; has api_username => ( - is => 'rw', - isa => 'Str', + is => 'rw', + isa => 'Str', predicate => 'has_api_username', ); has api_password => ( - is => 'rw', - isa => 'Str', + is => 'rw', + isa => 'Str', predicate => 'has_api_password', ); @@ -26,7 +26,9 @@ after BUILDALL => sub { $self->$_($value) if $value && !$self->$predicate; } - if (my $has_auth = $self->meta->get_api_option('authentication')) { + if ( $self->meta->get_api_option('authentication') + || $self->meta->get_api_option('authentication_method')) + { my $auth_method = $self->meta->get_api_option('authentication_method'); if ($auth_method) { $self->api_useragent->add_handler( @@ -61,3 +63,5 @@ after BUILDALL => sub { =item B =back +64: hit eof while in pod documentation (no =cut seen) + this can cause trouble with some pod utilities diff --git a/lib/MooseX/Net/API/Role/Serialization.pm b/lib/MooseX/Net/API/Role/Serialization.pm index f10a101..92c0248 100644 --- a/lib/MooseX/Net/API/Role/Serialization.pm +++ b/lib/MooseX/Net/API/Role/Serialization.pm @@ -50,7 +50,8 @@ sub deserialize { my $s = $self->_get_serializer($format) || $self->_load_serializer($format); next unless $s; - my $result = try { $s->decode($content) }; + my $result; + try { $result = $s->decode($content) }; return $result if $result; } } -- cgit 1.4.1