X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=examples%2FPerl6Attribute.pod;h=4b3a6d5dfb2ca09fce6d24f15638c81be7ceb85b;hb=25803581ff9edc2c7ab78dd0493a9a06a9b13f51;hp=930c6cdee6a43cfcf0891e1249dd8e7e52af3516;hpb=5659d76e5bb87873fa7c80efdf1cce8c40d40237;p=gitmo%2FClass-MOP.git diff --git a/examples/Perl6Attribute.pod b/examples/Perl6Attribute.pod index 930c6cd..4b3a6d5 100644 --- a/examples/Perl6Attribute.pod +++ b/examples/Perl6Attribute.pod @@ -5,11 +5,12 @@ package # hide the package from PAUSE use strict; use warnings; -our $VERSION = '0.01'; +our $VERSION = '0.02'; use base 'Class::MOP::Attribute'; -sub new { +Perl6Attribute->meta->add_around_method_modifier('new' => sub { + my $cont = shift; my ($class, $attribute_name, %options) = @_; # extract the sigil and accessor name @@ -22,8 +23,8 @@ sub new { $options{default} = sub { [] } if ($sigil eq '@'); $options{default} = sub { {} } if ($sigil eq '%'); - $class->SUPER::new($attribute_name, %options); -} + $cont->($class, $attribute_name, %options); +}); 1; @@ -39,8 +40,6 @@ Perl6Attribute - An example attribute metaclass for Perl 6 style attributes package Foo; - use Class::MOP 'meta'; - Foo->meta->add_attribute(Perl6Attribute->new('$.foo')); Foo->meta->add_attribute(Perl6Attribute->new('@.bar')); Foo->meta->add_attribute(Perl6Attribute->new('%.baz'));