Search code examples
perlmoose

How can I cast an existing Moose object into an extending instance?


I have a Moose class named 'Child' which extends another class named 'Person'. Given a 'Person' instance I would like to create a Child instance.

How can I cast the existing 'Person' into a 'Child', without explicitly creating a new Child and passing each of the arguments from `Person'?


Solution

  • Class::MOP::Class::rebless_instance