1MooseX::GlobRef::Role::UOsbejrecCto(n3t)ributed Perl DocMuomoesnetXa:t:iGolnobRef::Role::Object(3)
2
3
4
6 MooseX::GlobRef::Role::Object - An object role for MooseX::GlobRef
7
9 Moose::Util::MetaRole::apply_base_class_roles(
10 for_class => $caller,
11 roles => [ 'MooseX::GlobRef::Role::Object' ],
12 );
13
14 package My::IO::File;
15
16 use Moose;
17
18 extends 'Moose::Object', 'IO::File';
19 with 'MooseX::GlobRef::Role::Object';
20
21 has 'file' => ( is => 'ro', isa => 'Str', required => 1 );
22 has 'mode' => ( is => 'ro', isa => 'Str', default => 'r' );
23
24 sub BUILD {
25 my ($fh) = @_;
26 $fh->open( $fh->file, $fh->mode );
27 };
28
29 sub slurp {
30 my ($fh) = @_;
31 local $/ = undef;
32 return $fh->getline;
33 };
34
35 my $io = My::IO::File->new( file => '/etc/passwd' );
36 print "::::::::::::::\n";
37 print $io->file, "\n";
38 print "::::::::::::::\n";
39 print $io->slurp;
40
42 This is a role for Moose::Object which is applied by MooseX::GlobRef.
43 It allows to store Moose object in glob reference of file handle.
44
45 The MooseX::GlobRef package should be used instead for Moose classes
46 but the "MooseX::GlobRef::Role::Object" can be helpful if you want to
47 extend non-Moose classes like IO::File or File::Temp.
48
50 <<around>> dump( maxdepth : Int = 1 ) : Array|Str
51 Dumps the object itself and also a hash slot of glob reference of
52 this object. It returns an array or string depended on context.
53
54 See Moose::Object.
55
57 MooseX::GlobRef, Moose::Object, Moose::Role.
58
60 Piotr Roszatycki <dexter@cpan.org>
61
63 Copyright (c) 2007, 2008, 2009, 2010 Piotr Roszatycki
64 <dexter@cpan.org>.
65
66 This is free software; you can redistribute it and/or modify it under
67 the same terms as perl itself.
68
69 See <http://dev.perl.org/licenses/artistic.html>
70
71
72
73perl v5.32.1 2021-01-27 MooseX::GlobRef::Role::Object(3)