3 package MooseX::Clone::Meta::Attribute::Trait::NoClone;
6 use namespace::clean -except => [qw(meta)];
8 with qw(MooseX::Clone::Meta::Attribute::Trait::Clone::Base);
10 sub Moose::Meta::Attribute::Custom::Trait::NoClone::register_implementation { __PACKAGE__ }
13 my ( $self, $target, $proto, %args ) = @_;
15 # FIXME default cloning behavior works like this
16 #if ( exists $args{init_arg} ) {
17 # $self->set_value($args{init_arg});
19 # but i think this is more correct
21 $self->clear_value($target);
22 $self->initialize_instance_slot(
23 $self->meta->get_meta_instance,
25 { exists $args{init_arg} ? ( $self->init_arg => $args{init_arg} ) : () },
37 MooseX::Clone::Meta::Attribute::Trait::NoClone - A trait for attrs that should
38 not be copied while cloning.
42 with qw(MooseX::Clone);
44 has _some_special_thingy => (
45 traits => [qw(NoClone)],
50 Sometimes certain values should not be carried over when cloning an object.
52 This attribute trait implements just that.
60 If the C<init_arg> param is set (that means an explicit value was given to
61 C<clone>) sets the attribute to that value.
63 Otherwise calls C<clear_value> and C<initialize_instance_slot>.