use B 'perlstring';
sub register_attribute_specs {
- my ($self, %spec) = @_;
- @{$self->{attribute_specs}||={}}{keys %spec} = values %spec;
+ my ($self, @new_specs) = @_;
+ my $specs = $self->{attribute_specs}||={};
+ while (my ($name, $new_spec) = splice @new_specs, 0, 2) {
+ $new_spec->{index} = scalar keys %$specs
+ unless defined $new_spec->{index};
+ $specs->{$name} = $new_spec;
+ }
$self;
}
sub construction_string {
my ($self) = @_;
- $self->{construction_string} or 'bless({}, $class);'
+ $self->{construction_string}
+ or 'bless('
+ .$self->accessor_generator->default_construction_string
+ .', $class);'
}
sub install_delayed {
}
$body .= ' return $new;'."\n";
if ($into->can('DEMOLISH')) {
- { local $@; require Method::Generate::DemolishAll; }
+ require Method::Generate::DemolishAll;
Method::Generate::DemolishAll->new->generate_method($into);
}
quote_sub
sub _handle_subconstructor {
my ($self, $into, $name) = @_;
- if (my $gen = $self->{subconstructor_generator}) {
+ if (my $gen = $self->{subconstructor_handler}) {
' if ($class ne '.perlstring($into).') {'."\n".
- ' '.$gen.";\n".
- ' return $class->'.$name.'(@_)'.";\n".
+ $gen.
' }'."\n";
} else {
''
sub _generate_args_via_buildargs {
my ($self) = @_;
- q{ my $args = $class->BUILDARGS(@_);}."\n";
+ q{ my $args = $class->BUILDARGS(@_);}."\n"
+ .q{ die "BUILDARGS did not return a hashref" unless ref($args) eq 'HASH';}
+ ."\n";
}
# inlined from Moo::Object - update that first.