Moose inheritance
package Employee;
use Moose;
use Id;
extends ('Person');
has id => ( is => 'ro', default => Id::next() );
has title => ( is => 'rw', isa => 'Str' );
1;
- 'extends' is recommended over use base because use base pushes on the end of @ISA and extends replaces @ISA
- This is important to ensure that classes which do not have super-classes still properly inherit from Moose::Object
- the 'default' key specifies a default value
- references must be wrapped in a code ref but any value can be wrapped in a code ref
- default can be augmented by the 'lazy' keyword, It only sets value when called by the reader method
- lazy => 1 # if lazy is used, a default must be present