Crypt::Random::Source::Base::File - File (or device) random data sources


Crypt-Random-Source documentation Contained in the Crypt-Random-Source distribution.

Index


Code Index:

NAME

Top

Crypt::Random::Source::Base::File - File (or device) random data sources

SYNOPSIS

Top

    use Moose;
    extends qw(Crypt::Random::Source::Base::File);

    has '+path' => (
        default => "/foo/bar",
    );

DESCRIPTION

Top

This is a base class for file (or file like) random data sources.

ATTRIBUTES

Top

path

A required attribute, the path to the file to open.

METHODS

Top

open_handle

Uses IO::File to open path for reading.

AUTHOR

Top

  Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT AND LICENSE

Top


Crypt-Random-Source documentation Contained in the Crypt-Random-Source distribution.

package Crypt::Random::Source::Base::File;
BEGIN {
  $Crypt::Random::Source::Base::File::AUTHORITY = 'cpan:NUFFIN';
}
BEGIN {
  $Crypt::Random::Source::Base::File::VERSION = '0.07';
}
# ABSTRACT: File (or device) random data sources

use Any::Moose;

use Carp qw(croak);

extends qw(Crypt::Random::Source::Base::Handle);

use IO::File;

has path => (
    is => "rw",
    required => 1,
);

sub open_handle {
    my ( $self, $mode ) = @_;

    my $file = $self->path;

    my $fh = IO::File->new;

    $fh->open($file, $mode || "r")
        or croak "open($file): $!";

    return $fh;
}

1;


# ex: set sw=4 et:


__END__