X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=examples%2FLazyClass.pod;h=262cd73d939df0901e41af647866f1d045e2af98;hb=0310d95d482349208449c86f91b5aa661d6411d4;hp=d884096e81d28939b2de2978fd41005a80d844ce;hpb=1a09d9cce4930577a39060a03029a32cd51d41c7;p=gitmo%2FClass-MOP.git diff --git a/examples/LazyClass.pod b/examples/LazyClass.pod index d884096..262cd73 100644 --- a/examples/LazyClass.pod +++ b/examples/LazyClass.pod @@ -7,7 +7,7 @@ use warnings; use Carp 'confess'; -our $VERSION = '0.04'; +our $VERSION = '0.05'; use base 'Class::MOP::Attribute'; @@ -24,8 +24,22 @@ sub initialize_instance_slot { } } +sub accessor_metaclass { 'LazyClass::Method::Accessor' } + +package # hide the package from PAUSE + LazyClass::Method::Accessor; + +use strict; +use warnings; + +use Carp 'confess'; + +our $VERSION = '0.01'; + +use base 'Class::MOP::Method::Accessor'; + sub generate_accessor_method { - my $attr = shift; + my $attr = (shift)->associated_attribute; my $attr_name = $attr->name; my $meta_instance = $attr->associated_class->get_meta_instance; @@ -46,7 +60,7 @@ sub generate_accessor_method { } sub generate_reader_method { - my $attr = shift; + my $attr = (shift)->associated_attribute; my $attr_name = $attr->name; my $meta_instance = $attr->associated_class->get_meta_instance; @@ -63,8 +77,6 @@ sub generate_reader_method { }; } - - package # hide the package from PAUSE LazyClass::Instance; @@ -96,17 +108,17 @@ LazyClass - An example metaclass with lazy initialization ':instance_metaclass' => 'LazyClass::Instance', ); - BinaryTree->meta->add_attribute('$:node' => ( + BinaryTree->meta->add_attribute('node' => ( accessor => 'node', init_arg => ':node' )); - BinaryTree->meta->add_attribute('$:left' => ( + BinaryTree->meta->add_attribute('left' => ( reader => 'left', default => sub { BinaryTree->new() } )); - BinaryTree->meta->add_attribute('$:right' => ( + BinaryTree->meta->add_attribute('right' => ( reader => 'right', default => sub { BinaryTree->new() } )); @@ -141,7 +153,7 @@ Yuval Kogman Enothingmuch@woobling.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006 by Infinity Interactive, Inc. +Copyright 2006-2008 by Infinity Interactive, Inc. L