whole bunch of stuff
[gitmo/Class-MOP.git] / examples / InsideOutClass.pod
index b371c15..653f917 100644 (file)
@@ -5,9 +5,7 @@ package # hide the package from PAUSE
 use strict;
 use warnings;
 
-use Class::MOP 'meta';
-
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 use Scalar::Util 'refaddr';
 
@@ -18,10 +16,10 @@ sub construct_instance {
     # create a scalar ref to use as 
     # the inside-out instance
     my $instance = \(my $var);
-    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;
+        my $init_arg = $attr->init_arg();
         # try to fetch the init arg from the %params ...
         my $val;        
         $val = $params{$init_arg} if exists $params{$init_arg};
@@ -34,17 +32,13 @@ sub construct_instance {
     return $instance;
 }
 
-sub attribute_metaclass { 'InsideOutClass::Attribute' }
-
 package # hide the package from PAUSE
     InsideOutClass::Attribute;
 
 use strict;
 use warnings;
 
-use Class::MOP 'meta';
-
-our $VERSION = '0.03';
+our $VERSION = '0.04';
 
 use Scalar::Util 'refaddr';
 
@@ -96,7 +90,12 @@ InsideOutClass - A set of example metaclasses which implement the Inside-Out tec
 
   package Foo;
   
-  sub meta { InsideOutClass->initialize($_[0]) }
+  use metaclass 'InsideOutClass' => (
+     # tell our metaclass to use the 
+     # InsideOut attribute metclass 
+     # to construct all it's attributes
+    ':attribute_metaclass' => 'InsideOutClass::Attribute'
+  );
   
   __PACKAGE__->meta->add_attribute('foo' => (
       reader => 'get_foo',
@@ -105,8 +104,8 @@ InsideOutClass - A set of example metaclasses which implement the Inside-Out tec
   
   sub new  {
       my $class = shift;
-      bless $class->meta->construct_instance(@_) => $class;
-  }  
+      $class->meta->new_object(@_);
+  } 
 
   # now you can just use the class as normal