MooseX::Types::CacheFileHandle - Type for special cached file handle


File-Stat-Moose documentation Contained in the File-Stat-Moose distribution.

Index


Code Index:

NAME

Top

MooseX::Types::CacheFileHandle - Type for special cached file handle

SYNOPSIS

Top

  package My::Class;
  use Moose;
  use MooseX::Types::CacheFileHandle;
  has fh => ( isa => 'CacheFileHandle' );

  package main;
  my $obj = My::Class->new( fh => \*_ );

DESCRIPTION

Top

This module provides Moose type which represents special cached file handle - underscore (_) - which is used for stat tests.

SEE ALSO

Top

Moose::Util::TypeConstraints, File::Stat::Moose.

AUTHOR

Top

Piotr Roszatycki <dexter@cpan.org>

LICENSE

Top

Copyright (C) 2007, 2008, 2009 by Piotr Roszatycki <dexter@cpan.org>.

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

See http://www.perl.com/perl/misc/Artistic.html


File-Stat-Moose documentation Contained in the File-Stat-Moose distribution.

#!/usr/bin/perl -c

package MooseX::Types::CacheFileHandle;


use 5.008;
use strict;
use warnings;

our $VERSION = '0.06';

use Moose::Util::TypeConstraints;


subtype CacheFileHandle => (
    as 'GlobRef',
    where {
        defined Scalar::Util::reftype($_)
        && Scalar::Util::reftype($_) eq 'GLOB'
        && $_ == \*_
    },
    optimize_as {
        defined $_[0]
        && defined Scalar::Util::reftype($_[0])
        && Scalar::Util::reftype($_[0]) eq 'GLOB'
        && $_[0] == \*_
    },
);


1;


__END__