summaryrefslogtreecommitdiff
path: root/lib/MooseX/UserAgent/Config.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2009-07-17 17:17:54 +0200
committerfranck cuny <franck@lumberjaph.net>2009-07-17 17:17:54 +0200
commitee4d87281ff498b5491e5ab06684379198ace86b (patch)
treee3503989bd7fc4eb8cf7669e6691c921f03a7448 /lib/MooseX/UserAgent/Config.pm
parentupdate (c) (diff)
downloadmoosex-useragent-ee4d87281ff498b5491e5ab06684379198ace86b.tar.gz
up
Diffstat (limited to '')
-rw-r--r--lib/MooseX/UserAgent/Config.pm21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/MooseX/UserAgent/Config.pm b/lib/MooseX/UserAgent/Config.pm
index cf453b0..d31a4dd 100644
--- a/lib/MooseX/UserAgent/Config.pm
+++ b/lib/MooseX/UserAgent/Config.pm
@@ -1,23 +1,29 @@
package MooseX::UserAgent::Config;
use Moose::Role;
+use Carp qw/croak/;
has 'agent' => (
isa => 'Object',
is => 'rw',
lazy => 1,
default => sub {
- my $self = shift;
- my $ua = $self->_LWPLIB->new;
+ my $self = shift;
+ my $class = $self->_LWPLIB;
+ eval " require $class ";
+ if ($@) {
+ croak "can't load " . $self->_LWPLIB . " : " . $@;
+ }
+ my $ua = $self->_LWPLIB->new;
- if (!$self->can('useragent_conf')) {
- # TODO
+ if ( !$self->can('useragent_conf') ) {
+ croak "no useragent_conf";
}
my $conf = $self->useragent_conf;
- $ua->agent( $conf->{name} ) if $conf->{name};
- $ua->from( $conf->{mail} ) if $conf->{mail};
+ $ua->agent( $conf->{name} ) if $conf->{name};
+ $ua->from( $conf->{mail} ) if $conf->{mail};
$ua->max_size( $conf->{max_size} ) if $conf->{max_size};
- $ua->timeout( $conf->{timeout} || 180 );
+ $ua->timeout( $conf->{timeout} || 180 );
$ua;
}
);
@@ -107,6 +113,7 @@ franck cuny C<< <franck.cuny@rtgi.fr> >>
Copyright (c) 2009, RTGI
All rights reserved.
+L<http://rtgi.fr/>
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.