The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MooseX::GlobRef::Meta::Instance - Instance metaclass for globref objects

SYNOPSIS

  package My::IO;

  use metaclass 'Moose::Meta::Class' =>
      instance_metaclass => 'MooseX::GlobRef::Meta::Instance';

  use Moose;

  has 'filename' => ( is => 'ro', isa => 'Str', required => 1 );

  sub open {
    my $fh = shift;
    my $hashref = ${*$fh};
    open $fh, $hashref->{filename} or confess "cannot open";
    return $fh;
  }

  sub getlines {
    my $fh = shift;
    return readline $fh;
  }

  my $io = new My::IO filename=>'/etc/passwd';
  print "::::::::::::::\n";
  print $io->filename, "\n";
  print "::::::::::::::\n";
  $io->open;
  print $io->getlines;
  

DESCRIPTION

This instance metaclass allows to store Moose object in glob reference or file handle. It can be used directly with metaclass pragma or with MooseX::GlobRef::Object base class.

Notice, that "use metaclass" have to be before "use Moose".

BASE CLASSES

METHODS

create_instance
get_slot_value
set_slot_value
deinitialize_slot
is_slot_initialized
weaken_slot_value
inline_create_instance
inline_slot_access

The methods overrided by this class.

SEE ALSO

MooseX::GlobRef::Object, Moose::Meta::Instance, Moose, metaclass.

AUTHOR

Piotr Roszatycki <dexter@debian.org>

LICENSE

Copyright (C) 2007 by Piotr Roszatycki <dexter@debian.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