File Coverage

blib/lib/MooseX/Types/LWP/UserAgent.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package MooseX::Types::LWP::UserAgent;
2             # ABSTRACT: MooseX::Types for LWP::UserAgent objects
3              
4             our $VERSION = "0.02";
5              
6 1     1   728836 use warnings;
  1         3  
  1         34  
7 1     1   7 use strict;
  1         1  
  1         40  
8              
9 1     1   2158 use MooseX::Types -declare => ["UserAgent"];
  1         66561  
  1         11  
10 1     1   4588 use Moose::Util::TypeConstraints;
  1         2  
  1         4  
11 1     1   3755 use LWP::UserAgent ();
  1         102206  
  1         306  
12              
13             class_type "LWP::UserAgent";
14              
15             subtype UserAgent,
16             as "LWP::UserAgent",
17             message { "Must be a LWP::UserAgent object" };
18              
19             coerce UserAgent,
20             from "ArrayRef"
21             => via { LWP::UserAgent->new(@$_) },
22             from "HashRef"
23             => via { LWP::UserAgent->new(%$_) };
24              
25             1;
26              
27             __END__
28              
29             =pod
30              
31             =head1 NAME
32              
33             MooseX::Types::LWP::UserAgent - MooseX::Types for LWP::UserAgent objects
34              
35             =head1 SYNOPSIS
36              
37             use Moose;
38             use Moose::Util::TypeConstraints;
39             use MooseX::Types::LWP::UserAgent qw(UserAgent);
40              
41             has 'ua' => (
42             is => 'rw',
43             isa => 'UserAgent',
44             coerce => 1,
45             );
46              
47             =head1 DESCRIPTION
48              
49             Provides type constraints that match LWP::UserAgent objects. Also provides
50             coercions for ArrayRef and HashRef that call LWP::UserAgent->new with the
51             passed arguments.
52              
53             =head1 AUTHOR
54              
55             Robert Norris C<< <rob@eatenbyagrue.org> >>
56              
57             =head1 COPYRIGHT AND LICENSE
58              
59             Copyright 2010 Robert Norris, all rights reserved.
60              
61             This module is free software; you can redistribute it and/or modify it under
62             the terms of the Artistic License v2.0. See
63             L<http://www.opensource.org/licenses/artistic-license-2.0.php> for details.
64              
65             =cut