MooseX...:Object(3pm)

πŸ“¦
version 0.0701 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

MooseX::GlobRef::Role::Object β€” bestie, it's a role for MooseX::GlobRef that lets you be an object and a filehandle at the same time πŸ¦‹

(also hi, this is a User Contributed Perl Documentation page, section 3pm, filed under MooseX...:Object(3pm) because the man page title got a lil truncated and honestly? iconic.)


✨ SYNOPSIS ✨

  Moose::Util::MetaRole::apply_base_class_roles(
      for_class => $caller,
      roles => [ 'MooseX::GlobRef::Role::Object' ],
  );

  package My::IO::File;

  use Moose;

  extends 'Moose::Object', 'IO::File';
  with 'MooseX::GlobRef::Role::Object';

  has 'file' => ( is => 'ro', isa => 'Str', required => 1 );
  has 'mode' => ( is => 'ro', isa => 'Str', default => 'r' );

  sub BUILD {
      my ($fh) = @_;
      $fh->open( $fh->file, $fh->mode );
  };

  sub slurp {
    my ($fh) = @_;
    local $/ = undef;
    return $fh->getline;
  };

  my $io = My::IO::File->new( file => '/etc/passwd' );
  print "::::::::::::::\n";
  print $io->file, "\n";
  print "::::::::::::::\n";
  print $io->slurp;

like, look at that. an object that is a glob ref. main character energy fr πŸ’…


🌸 DESCRIPTION 🌸

okay so. this is a role for Moose::Object that gets applied by MooseX::GlobRef. what it does is let you store a Moose object inside the glob reference of a file handle. yes really. object brain, filehandle body. it's giving duality 🫢

now, if you're building straight-up Moose classes, you should be using the MooseX::GlobRef package instead, no cap. but β€” and this is the tea β˜• β€” MooseX::GlobRef::Role::Object is genuinely the move when you want to extend non-Moose classes like IO::File or File::Temp. those cuties aren't Moose, so you can't just inherit the whole thing. you need the role. iykyk πŸ’œ


πŸŽ€ METHODS πŸŽ€

<<around>> dump( maxdepth : Int = 1 ) : Array|Str

so this one is wrapped in an around modifier ✨ it dumps the object itself plus a hash slot of the glob reference of this object. two for one, we love a bonus.

the return value is an Array or a Str β€” depended on context, so watch your scalar vs list vibes πŸ’…

go peek at Moose::Object for the full lore on how this works πŸ¦‹

πŸ‘‘ SEE ALSO πŸ‘‘

  • MooseX::GlobRef πŸ’–
  • Moose::Object 🌸
  • Moose::Role ✨

🧚 AUTHOR 🧚

Piotr Roszatycki <dexter@cpan.org> β€” legend behavior, honestly πŸ‘‘


πŸ’œ LICENSE πŸ’œ

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

this is free software; you can redistribute it and/or modify it under the same terms as perl itself. periodt πŸ’…

see <http://dev.perl.org/licenses/artistic.html> for the receipts πŸ”₯

and that's the whole page bestie!! πŸŽ€βœ¨

this was perl v5.42.0, dated 2025-07-25, from that MooseX...:Object(3pm) page in User Contributed Perl Documentation β€” mwah, go read some source code, ily πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from