ChangeLog and adding yuval to authors everywhere
[gitmo/Class-MOP.git] / examples / ClassEncapsulatedAttributes.pod
index 8a3dabc..326f527 100644 (file)
@@ -19,14 +19,15 @@ sub initialize {
 sub construct_instance {
     my ($class, %params) = @_;
 
-        my $instance = $class->get_meta_instance->create_instance();
+    my $meta_instance = $class->get_meta_instance;
+       my $instance = $meta_instance->create_instance();
 
        # initialize *ALL* attributes, including masked ones (as opposed to applicable)
     foreach my $current_class ($class->class_precedence_list()) {
         my $meta = $current_class->meta;
         foreach my $attr_name ($meta->get_attribute_list()) {
             my $attr = $meta->get_attribute($attr_name);
-            $attr->initialize_instance_slot($instance, \%params);
+            $attr->initialize_instance_slot($meta_instance, $instance, \%params);
         }
     }  
 
@@ -45,7 +46,7 @@ use base 'Class::MOP::Attribute';
 
 # alter the way parameters are specified
 sub initialize_instance_slot {
-    my ($self, $instance, $params) = @_;
+    my ($self, $meta_instance, $instance, $params) = @_;
     # if the attr has an init_arg, use that, otherwise,
     # use the attributes name itself as the init_arg
     my $init_arg = $self->init_arg();
@@ -62,14 +63,12 @@ sub initialize_instance_slot {
     }
 
     # now add this to the instance structure
-       my $meta_instance = $self->associated_class->get_meta_instance;
-       $meta_instance->set_slot_value_with_init( $instance, $self->slot_name, $val );
+    $meta_instance->set_slot_value($instance, $self->name, $val);
 }
 
-# mangle the slot name to include the fully qualified attr
-sub slot_name {
-       my $self = shift;
-       $self->associated_class->name . "::" . $self->SUPER::slot_name;
+sub name {
+    my $self = shift;
+    return ($self->associated_class->name . '::' . $self->SUPER::name)    
 }
 
 1;
@@ -134,10 +133,12 @@ is similar to how C++ handles its data members.
 
 Thanks to Yuval "nothingmuch" Kogman for the idea for this example.
 
-=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.