
MooseX::Types::IO::All - IO::All related constraints and coercions for Moose

package Foo;
use Moose;
use MooseX::Types::IO::All 'IO_All';
has io => (
isa => IO_All,
is => "rw",
coerce => 1,
);
# later
my $str = "test for IO::String\n line 2";
my $foo = Foo->new( io => \$str );
my $io = $foo->io; # IO::All::String
# or
my $filename = "file.txt";
my $foo = Foo->new( io => $filename );
my $io = $foo->io; # IO::All

This module packages one Moose::Util::TypeConstraints with coercions, designed to work with the IO::All suite of objects.

io $_;
IO::All object.
my $s = io('$');
$s->print($$_);
IO::All::String object. so generally u need
${ $s->string_ref } # the content
instead of ->all or ->slurp

Moose, MooseX::Types, MooseX::Types::IO, IO::All

Fayland Lam, <fayland at gmail.com>

The Moose Team

Copyright 2008 Fayland Lam, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.