NAME

Mojo::Autobox - Some extra Mojo for Perl native datatypes

SYNOPSIS

use Mojo::Base -strict;
use Mojo::Autobox;

# "site.com\n"
'{"html": "<a href=\"http://site.com\"></a>"}'
  ->json('/html')
  ->dom->at('a')->{href}
  ->url->host
  ->byte_stream->say;

DESCRIPTION

Using autobox, methods are provided to Perl native datatypes. This ability is then used to provide methods useful with classes from the Mojolicious toolkit. These are especially useful to contruct objects to continue a "chain" of method invocations.

The effect is lexical, and therefore is contained within the scope that the module is imported into.

CLASSES

When the pragma is in effect, the types are effectively blessed into the following classes:

STRING - Mojo::Autobox::String
ARRAY - Mojo::Autobox::Array
HASH - Mojo::Autobox::Hash

ONE-LINERS

Additionally, for one-liner fun, the class ojoBox may be used to load Mojo::Autobox and ojo.

perl -MojoBox -E 'g("http://mojolicio.us")->dom->find("a")->each(sub{$_->{href}->url->host->b->say})'

SOURCE REPOSITORY

http://github.com/jberger/Mojo-Autobox

AUTHOR

Joel Berger, <joel.a.berger@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Joel Berger

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.