[Moose-commits] r7443 - in
MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef: . Meta
dexter at code2.0beta.co.uk
dexter at code2.0beta.co.uk
Sat Jan 31 12:23:08 GMT 2009
Author: dexter
Date: 2009-01-31 04:23:08 -0800 (Sat, 31 Jan 2009)
New Revision: 7443
Modified:
MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Meta/Class.pm
MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Meta/Instance.pm
MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Object.pm
Log:
* POD.
Modified: MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Meta/Class.pm
===================================================================
--- MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Meta/Class.pm 2009-01-31 11:48:23 UTC (rev 7442)
+++ MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Meta/Class.pm 2009-01-31 12:23:08 UTC (rev 7443)
@@ -2,7 +2,7 @@
package MooseX::GlobRef::Meta::Class;
-=head1 NAME
+=head1 NAME
MooseX::GlobRef::Meta::Class - Metaclass for globref objects
@@ -28,16 +28,48 @@
__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
+
=head1 SEE ALSO
L<MooseX::GlobRef::Object>, L<Moose::Meta::Object>, L<Moose>, L<metaclass>.
Modified: MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Meta/Instance.pm
===================================================================
--- MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Meta/Instance.pm 2009-01-31 11:48:23 UTC (rev 7442)
+++ MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Meta/Instance.pm 2009-01-31 12:23:08 UTC (rev 7443)
@@ -2,7 +2,7 @@
package MooseX::GlobRef::Meta::Instance;
-=head1 NAME
+=head1 NAME
MooseX::GlobRef::Meta::Instance - Instance metaclass for globref objects
@@ -10,8 +10,9 @@
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 @@
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 @@
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 is_slot_initialized {
my ($self, $instance, $slot_name) = @_;
- return exists do { \%{*$instance} }->{$slot_name} ? 1 : 0;
+ return exists do { \%{*$instance} }->{$slot_name};
};
@@ -115,16 +116,32 @@
__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
+
=head1 METHODS
=over
Modified: MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Object.pm
===================================================================
--- MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Object.pm 2009-01-31 11:48:23 UTC (rev 7442)
+++ MooseX-GlobRef-Object/trunk/lib/MooseX/GlobRef/Object.pm 2009-01-31 12:23:08 UTC (rev 7443)
@@ -2,7 +2,7 @@
package MooseX::GlobRef::Object;
-=head1 NAME
+=head1 NAME
MooseX::GlobRef::Object - Store a Moose object in glob reference
@@ -33,18 +33,26 @@
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 @@
=for readme stop
-=head1 BASE CLASSES
+=head1 INHERITANCE
=over 2
=item *
-L<Moose::Object>
+extends L<Moose::Object>
=back
More information about the Moose-commits
mailing list