NAME

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

SYNOPSIS

    package Foo;

    use Moose;
    use MooseX::Types::IO 'IO';

    has io => (
        isa => IO,
        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::String
    # or
    my $filename = "file.txt";
    my $foo = Foo->new( io => $filename );
    my $io  = $foo->io; # IO::File
    # or
    my $foo = Foo->new( io => [ $fh, '<' ] );
    my $io  = $foo->io; # IO::Handle

DESCRIPTION

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

CONSTRAINTS

Str
    my $fh = new IO::File;
    $fh->open($_);

IO::File object.

ScalarRef
    IO::String->new($$_);

IO::String object.

ArrayRef[FileHandle|Str]
    IO::Handle->new_from_fd( @$_ );

IO::Handle object.

SEE ALSO

Moose, MooseX::Types, MooseX::Types::IO::All, IO::Hanlde, IO::File, IO::String

AUTHOR

Fayland Lam, <fayland at gmail.com>

ACKNOWLEDGEMENTS

The Moose Team

Rafael Kitover (rkitover) for the patches on RT 46194

COPYRIGHT & LICENSE

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.