Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / example / traits.pl
CommitLineData
a41b51bd 1#!perl
2package IntStack;
3use Mouse;
4
5has storage => (
6 is => 'ro',
7 isa => 'ArrayRef[Int]',
8
9 default => sub{ [] },
10 traits => [qw(Array)],
11
12 handles => {
13 push => 'push',
14 pop => 'pop',
15 top => [ get => -1 ],
16 },
17);
18
19__PACKAGE__->meta->make_immutable();
20
21package main;
22
23my $stack = IntStack->new;
24
25$stack->push(42);
26$stack->push(27);
27
28print $stack->pop, "\n";
29print $stack->top, "\n";
30