sub new {
my ($class, $name, %options) = @_;
- $class->_process_options($name, \%options);
+ $class->_process_options($name, \%options) unless $options{__hack_no_process_options}; # used from clone()... YECHKKK FIXME ICKY YUCK GROSS
+
+ delete $options{__hack_no_process_options};
+
my %attrs =
( map { $_ => 1 }
grep { defined }
my @found_illegal_options = grep { exists $options{$_} && exists $self->{$_} ? $_ : undef } @illegal_options;
(scalar @found_illegal_options == 0)
|| $self->throw_error("Illegal inherited options => (" . (join ', ' => @found_illegal_options) . ")", data => \%options);
-
-
+
+
# NOTE:
# this doesn't apply to Class::MOP::Attributes,
# so we can ignore it for them.
$options{traits} = \@all_traits if @all_traits;
}
-
$self->clone(%options);
}
push @{ $attr->has_init_arg ? \@init : \@non_init }, $attr;
}
- my %new_params = ( ( map { $_->init_arg => $_->get_value($self) } @init ), %params );
+ my %init_params = ( map { $_->init_arg => $_->get_value($self) } @init );
+
+ $self->_process_clone_options($self->name, \%params, \%init_params);
- my $name = delete $new_params{name};
+ my %new_params = ( %init_params, %params );
- my $clone = $class->new($name, %new_params);
+ my $name = delete $new_params{name};
+
+ my $clone = $class->new($name, %new_params, __hack_no_process_options => 1 );
foreach my $attr ( @non_init ) {
$attr->set_value($clone, $attr->get_value($self));
return $clone;
}
+sub _process_clone_options {
+ my ( $class, $name, $options, $parent_options ) = @_;
+ $class->_process_isa_option( $name, $options, $parent_options );
+ $class->_process_does_option( $name, $options, $parent_options );
+ $class->_process_lazy_build_option( $name, $options, $parent_options );
+}
+
sub _process_options {
my ( $class, $name, $options ) = @_;
+ $class->_process_is_option( $name, $options );
$class->_process_isa_option( $name, $options );
$class->_process_does_option( $name, $options );
- $class->_process_is_option( $name, $options );
$class->_process_coerce_option( $name, $options );
$class->_process_trigger_option( $name, $options );
$class->_process_auto_deref_option( $name, $options );
$class->_process_required_option( $name, $options );
}
-
sub _process_is_option {
my ( $class, $name, $options ) = @_;