X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP.pm;h=7b01847fe52151b6399eb8e715adc372afd6a5c8;hb=5659d76e5bb87873fa7c80efdf1cce8c40d40237;hp=f40f794b3280ed81cec19869e32ee1dfcbd2904a;hpb=526ba574c9dfda8f386f44c36a7f05d815155deb;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index f40f794..7b01847 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -147,12 +147,16 @@ Class::MOP::Attribute->meta->add_method('new' => sub { (defined $name && $name) || confess "You must provide a name for the attribute"; - (!exists $options{reader} && !exists $options{writer}) - || confess "You cannot declare an accessor and reader and/or writer functions" - if exists $options{accessor}; - $options{init_arg} = $name if not exists $options{init_arg}; + $options{init_arg} = $name + if not exists $options{init_arg}; - bless $class->meta->construct_instance(name => $name, %options) => blessed($class) || $class; + # return the new object + $class->meta->new_object(name => $name, %options); +}); + +Class::MOP::Attribute->meta->add_method('clone' => sub { + my $self = shift; + $self->meta->clone_object($self, @_); }); 1;