in reply to changing moose object classes on the go
Pretty much the same sort of question I asked a while ago here. The quick answer is as follows:
and somewhere in user space:package Dog; use Moose; has 'breed' => ( is => 'ro',isa=>'String'); has 'color' => ( is => 'rw', isa=>'String'); sub BUILD { my $self =shift; my $class = "Dog::" . $self->breed(); $class->meta->rebless_instance($self); } 1;
| handwaving here.. use Dog; # updated this on 2013-04-24, error in original code my $dog = Dog->new(breed=>'Poodle'); | |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: changing moose object classes on the go
by tomgracey (Scribe) on Apr 24, 2013 at 09:55 UTC |