X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=examples%2FLazyClass.pod;h=cb678b14e49b8a1bd884058fa195dbdc396a5d10;hb=c9e77dbb017258dc44295fc4ec8e0bdd99ec9361;hp=e0155127104a336ece0db732dec9754334fb4084;hpb=4300f56aa63b9e0201ce6d541ee03ac5b6d4ee75;p=gitmo%2FClass-MOP.git diff --git a/examples/LazyClass.pod b/examples/LazyClass.pod index e015512..cb678b1 100644 --- a/examples/LazyClass.pod +++ b/examples/LazyClass.pod @@ -1,19 +1,18 @@ -package LazyClass; +package # hide the package from PAUSE + LazyClass; use strict; use warnings; -use Class::MOP 'meta'; - -our $VERSION = '0.01'; +our $VERSION = '0.02'; use base 'Class::MOP::Class'; sub construct_instance { my ($class, %params) = @_; my $instance = {}; - foreach my $attr (map { $_->{attribute} } $class->compute_all_applicable_attributes()) { + foreach my $attr ($class->compute_all_applicable_attributes()) { # if the attr has an init_arg, use that, otherwise, # use the attributes name itself as the init_arg my $init_arg = $attr->has_init_arg() ? $attr->init_arg() : $attr->name; @@ -27,14 +26,13 @@ sub construct_instance { return $instance; } -package LazyClass::Attribute; +package # hide the package from PAUSE + LazyClass::Attribute; use strict; use warnings; -use Class::MOP 'meta'; - -our $VERSION = '0.01'; +our $VERSION = '0.02'; use base 'Class::MOP::Attribute'; @@ -79,11 +77,9 @@ LazyClass - An example metaclass with lazy initialization package BinaryTree; - sub meta { - LazyClass->initialize($_[0] => ( - ':attribute_metaclass' => 'LazyClass::Attribute' - )); - } + use metaclass 'LazyClass' => ( + ':attribute_metaclass' => 'LazyClass::Attribute' + ); BinaryTree->meta->add_attribute('$:node' => ( accessor => 'node',