_enw for Method::Constructor
[gitmo/Class-MOP.git] / examples / LazyClass.pod
index f28a23e..262cd73 100644 (file)
@@ -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() }    
   ));    
@@ -133,13 +145,15 @@ without complicating the programing of it. This would also be
 ideal for a class which has a large amount of attributes, 
 several of which are optional. 
 
-=head1 AUTHOR
+=head1 AUTHORS
 
 Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
+Yuval Kogman E<lt>nothingmuch@woobling.comE<gt>
+
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006 by Infinity Interactive, Inc.
+Copyright 2006-2008 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>