Finished slides & exercises for section 3on basic attributes.
[gitmo/moose-presentations.git] / moose-class / exercises / answers / 03-basic-attributes / Employee.pm
1 package Employee;
2
3 use Moose;
4
5 extends 'Person';
6
7 has '+title' => (
8     default => 'Worker',
9 );
10
11 has salary_level => (
12     is      => 'rw',
13     default => 1,
14 );
15
16 has salary => (
17     is       => 'ro',
18     lazy     => 1,
19     builder  => '_build_salary',
20     init_arg => undef,
21 );
22
23 has ssn    => ( is => 'ro' );
24
25 sub _build_salary {
26     my $self = shift;
27
28     return $self->salary_level * 10000;
29 }
30
31 no Moose;
32
33 __PACKAGE__->meta->make_immutable;
34
35 1;