X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FPurePerl.pm;h=44390ed808abfa05b3c0499cbb2d86bb902db405;hp=643795aabfa50ec594484ec45852814a0573e298;hb=13b9990881cb1c765a47711fc4eb0d47a404c756;hpb=537873b064ad328ea662e3792b128d9b016ed38a diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index 643795a..44390ed 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -288,6 +288,20 @@ sub new_object { return $object; } +sub clone_object { + my $class = shift; + my $object = shift; + my $args = $object->Mouse::Object::BUILDARGS(@_); + + (blessed($object) && $object->isa($class->name)) + || $class->throw_error("You must pass an instance of the metaclass (" . $class->name . "), not ($object)"); + + my $cloned = bless { %$object }, ref $object; + $class->_initialize_object($cloned, $args, 1); + + return $cloned; +} + sub _initialize_object{ my($self, $object, $args, $is_cloning) = @_;