more deeper scrubbing of the error output
[gitmo/MooseX-Types-Structured.git] / lib / MooseX / Types / Structured / MessageStack.pm
CommitLineData
14375407 1package MooseX::Types::Structured::MessageStack;
2use Moose;
3
4has 'level' => (
5 traits => ['Counter'],
6 is => 'ro',
7 isa => 'Num',
8 required => 0,
9 default => 0,
10 handles => {
11 inc_level => 'inc',
12 dec_level => 'dec',
13 },
14);
15
16# :level, :message, :tc
17has 'messages' => (
18 traits => ['Array'],
19 is => 'ro',
20 isa => 'ArrayRef[HashRef]',
21 required => 1,
22 default => sub { [] },
23 handles => {
24 has_messages => 'count',
25 add_message => 'push',
26 all_messages => 'elements',
27 },
28);
29
30sub as_string {
31 my @messages = (shift)->all_messages;
fbe3dfe7 32 my $message = join("", map { "\n". (" " x $_->{level}) ."[+] " . $_->{message} } reverse @messages);
14375407 33 return $message;
34}
35
36
37no Moose;
38__PACKAGE__->meta->make_immutable;
39
401;