32 my($self, $value) = @_;
33 $triggered{$self} = $value;
38 my ($self, @args) = @_;
39 $self->meta->clone_object($self, @args);
55 my ($self, @args) = @_;
56 $self->meta->clone_object($self, @args);
60 my $foo = Foo->new(bar => [ 1, 2, 3 ], quuux => "indeed");
62 is($foo->foo, "foo", "attr 1",);
63 is($foo->quux, "indeed", "init_arg respected");
65 is $triggered{$foo}, "indeed";
67 is_deeply($foo->bar, [ 1 .. 3 ], "attr 2");
70 my $clone = $foo->clone(foo => "dancing", baz => "bar", quux => "nope", quuux => "yes");
72 is $triggered{$foo}, "indeed";
73 is $triggered{$clone}, "yes", 'clone_object() invokes triggers';
75 is($clone->foo, "dancing", "overridden attr");
76 is_deeply($clone->bar, [ 1 .. 3 ], "clone attr");
77 is($clone->baz, "foo", "init_arg=undef means the attr is ignored");
78 is($clone->quux, "yes", "clone uses init_arg and not attribute name");
81 my $bar = Bar->new(id => 'xyz');
84 is_deeply $bar, $c, "clone() with required attributes";
88 Foo->meta->clone_object("constant");
89 } qr/You must pass an instance of the metaclass \(Foo\), not \(constant\)/;
92 Foo->meta->clone_object(Foo->meta)
93 } qr/You must pass an instance of the metaclass \(Foo\), not \(Mouse::Meta::Class=HASH\(\w+\)\)/;