Mojo/Autobox.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 17 / 17 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
import
1.0
CRAP 1.0
« Mojo/Autobox/String.pm ↑ Summary Mojo/Autobox/Array.pm »
1 package Mojo::Autobox;
2  
3 4 ▶use Mojo::Base -strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 our $VERSION = '0.03';
6 4 $VERSION = eval $VERSION;
7  
8 4 ▶use Mojo::Base 'autobox';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 require Mojo::Autobox::String;
11 4 require Mojo::Autobox::Array;
12 4 require Mojo::Autobox::Hash;
13  
14 4 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
15 4 my $class = shift;
16 4 $class->SUPER::import(
17 STRING => 'Mojo::Autobox::String',
18 ARRAY => 'Mojo::Autobox::Array',
19 HASH => 'Mojo::Autobox::Hash',
20 );
21 }
22  
23 4 1;
24  
25 =head1 NAME
26  
27 Mojo::Autobox - Some extra Mojo for Perl native datatypes
28  
29 =head1 SYNOPSIS
30  
31 use Mojo::Base -strict;
32 use Mojo::Autobox;
33  
34 # "site.com\n"
35 '{"html": "<a href=\"http://site.com\"></a>"}'
36 ->json('/html')
37 ->dom->at('a')->{href}
38 ->url->host
39 ->byte_stream->say;
40  
41 =head1 DESCRIPTION
42  
43 Using L<autobox>, methods are provided to Perl native datatypes.
44 This ability is then used to provide methods useful with classes from the L<Mojolicious> toolkit.
45 These are especially useful to contruct objects to continue a "chain" of method invocations.
46  
47 The effect is lexical, and therefore is contained within the scope that the module is imported into.
48  
49 =head1 CLASSES
50  
51 When the pragma is in effect, the types are effectively blessed into the following classes:
52  
53 =over
54  
55 =item STRING - L<Mojo::Autobox::String>
56  
57 =item ARRAY - L<Mojo::Autobox::Array>
58  
59 =item HASH - L<Mojo::Autobox::Hash>
60  
61 =back
62  
63 =head1 ONE-LINERS
64  
65 Additionally, for one-liner fun, the class L<ojoBox> may be used to load L<Mojo::Autobox> and L<ojo>.
66  
67 perl -MojoBox -E 'g("http://mojolicio.us")->dom->find("a")->each(sub{$_->{href}->url->host->b->say})'
68  
69 =head1 SOURCE REPOSITORY
70  
71 L<http://github.com/jberger/Mojo-Autobox>
72  
73 =head1 AUTHOR
74  
75 Joel Berger, E<lt>joel.a.berger@gmail.comE<gt>
76  
77 =head1 COPYRIGHT AND LICENSE
78  
79 Copyright (C) 2014 by Joel Berger
80  
81 This library is free software; you can redistribute it and/or modify
82 it under the same terms as Perl itself.
83  
« Mojo/Autobox/String.pm ↑ Summary Mojo/Autobox/Array.pm »