# so that it uses the attributes meta-objects
# to construct itself.
Class::MOP::Attribute->meta->add_method('new' => sub {
- my $class = shift;
- my $name = shift;
- my %options = @_;
+ my ( $class, @args ) = @_;
+
+ unshift @args, "name" if @args % 2 == 1;
+ my %options = @args;
+
+ my $name = $options{name};
(defined $name && $name)
|| confess "You must provide a name for the attribute";
}
# return the new object
- $class->meta->new_object(name => $name, %options);
+ $class->meta->new_object(%options);
});
Class::MOP::Attribute->meta->add_method('clone' => sub {
# meta-objects.
# - Ain't meta-circularity grand? :)
sub new {
- my $class = shift;
- my $name = shift;
- my %options = @_;
+ my ( $class, @args ) = @_;
+
+ unshift @args, "name" if @args % 2 == 1;
+ my %options = @args;
+
+ my $name = $options{name};
(defined $name && $name)
|| confess "You must provide a name for the attribute";