Permalink
Browse files

* POD.

  • Loading branch information...
1 parent 07a5fb9 commit f66122a720a2ea5fe10ea1967caa87c8aba7da84 dexter committed Jan 31, 2009
Showing with 81 additions and 24 deletions.
  1. +35 −3 lib/MooseX/GlobRef/Meta/Class.pm
  2. +31 −14 lib/MooseX/GlobRef/Meta/Instance.pm
  3. +15 −7 lib/MooseX/GlobRef/Object.pm
@@ -2,7 +2,7 @@
package MooseX::GlobRef::Meta::Class;
-=head1 NAME
+=head1 NAME
MooseX::GlobRef::Meta::Class - Metaclass for globref objects
@@ -28,13 +28,45 @@ use parent 'Moose::Meta::Class';
__END__
-=head1 BASE CLASSES
+=head1 INHERITANCE
=over 2
=item *
-L<Moose::Meta::Class>
+extends L<Moose::Meta::Class>
+
+=over 2
+
+=item *
+
+extends L<Class::MOP::Class>
+
+=over 2
+
+=item *
+
+extends L<Class::MOP::Module>
+
+=over 2
+
+=item *
+
+extends L<Class::MOP::Package>
+
+=over 2
+
+=item *
+
+extends L<Class::MOP::Object>
+
+=back
+
+=back
+
+=back
+
+=back
=back
@@ -2,16 +2,17 @@
package MooseX::GlobRef::Meta::Instance;
-=head1 NAME
+=head1 NAME
MooseX::GlobRef::Meta::Instance - Instance metaclass for globref objects
=head1 SYNOPSIS
package My::IO;
- use metaclass 'Moose::Meta::Class' =>
- instance_metaclass => 'MooseX::GlobRef::Meta::Instance';
+ use metaclass 'Moose::Meta::Class' => (
+ instance_metaclass => 'MooseX::GlobRef::Meta::Instance'
+ );
use Moose;
@@ -34,14 +35,14 @@ MooseX::GlobRef::Meta::Instance - Instance metaclass for globref objects
print "::::::::::::::\n";
$io->open;
print $io->getlines;
-
+
=head1 DESCRIPTION
-This instance metaclass allows to store Moose object in glob reference or
+This instance metaclass allows to store Moose object in glob reference of
file handle. It can be used directly with C<metaclass> pragma or with
L<MooseX::GlobRef::Object> base class.
-Notice, that "use metaclass" have to be before "use Moose".
+Notice, that C<use metaclass> have to be before C<use Moose>.
=cut
@@ -58,13 +59,13 @@ use parent 'Moose::Meta::Instance';
sub create_instance {
my ($self) = @_;
- # create anonymous filehandler
- select select my $fh;
+ # create anonymous file handle
+ select select my $instance;
- # associate hash slot with globref
- %{*$fh} = ();
+ # initialize hash slot of file handle
+ %{*$instance} = ();
- return bless $fh => $self->associated_metaclass->name;
+ return bless $instance => $self->associated_metaclass->name;
};
@@ -88,7 +89,7 @@ sub deinitialize_slot {
sub is_slot_initialized {
my ($self, $instance, $slot_name) = @_;
- return exists do { \%{*$instance} }->{$slot_name} ? 1 : 0;
+ return exists do { \%{*$instance} }->{$slot_name};
};
@@ -115,13 +116,29 @@ sub inline_slot_access {
__END__
-=head1 BASE CLASSES
+=head1 INHERITANCE
=over 2
=item *
-L<Moose::Meta::Instance>
+extends L<Moose::Meta::Instance>
+
+=over 2
+
+=item *
+
+extends L<Class::MOP::Instance>
+
+=over 2
+
+=item *
+
+extends L<Class::MOP::Object>
+
+=back
+
+=back
=back
@@ -2,7 +2,7 @@
package MooseX::GlobRef::Object;
-=head1 NAME
+=head1 NAME
MooseX::GlobRef::Object - Store a Moose object in glob reference
@@ -33,17 +33,25 @@ MooseX::GlobRef::Object - Store a Moose object in glob reference
print "::::::::::::::\n";
$io->open;
print $io->getlines;
-
+
=head1 DESCRIPTION
-This meta-policy allows to store Moose object in glob reference or file
+This meta-policy allows to store Moose object in glob reference of file
handle. The class attributes will be stored in hash slot associated with glob
reference. It allows to create a Moose version of L<IO::Handle>.
-The elements of hash can be accessed directly with following expression:
+The attributes can be accessed directly with following expression:
my $hashref = \%{*$self};
- $hashref->{key} = $value;
+ print $hashref->{key};
+
+or shorter:
+
+ print do { \%{*$self} }->{key};
+
+but the standard accessors should be used instead:
+
+ print $self->key;
You can use L<MooseX::GlobRef::Meta::Instance> metaclass directly if you need
more customised configuration.
@@ -71,13 +79,13 @@ __END__
=for readme stop
-=head1 BASE CLASSES
+=head1 INHERITANCE
=over 2
=item *
-L<Moose::Object>
+extends L<Moose::Object>
=back

0 comments on commit f66122a

Please sign in to comment.