in reply to Re: What is a reliable way to get the package of the code creating a Moose object?
in thread What is a reliable way to get the package of the code creating a Moose object?

Better:

package Child; # insert usual Moose stuff has context => (is => 'ro', isa => Str, init_arg => '_context', requir +ed => 1); sub new_for_parent { my $class = shift; $class->new(@_, _context => 'parent'); } sub new_for_teacher { my $class = shift; $class->new(@_, _context => 'teacher'); }

The parent and teacher create the child via different constructors.

(People don't think about creating custom constructors as often as they should.)

  • Comment on Re^2: What is a reliable way to get the package of the code creating a Moose object?
  • Download Code