Do the correct thing with type contraints etc to be able to serialize things
[catagits/Gitalist.git] / lib / Gitalist / Git / HasUtils.pm
1 use MooseX::Declare;
2
3 role Gitalist::Git::HasUtils {
4     use Gitalist::Git::Util;
5     use MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize;
6
7     method BUILD {}
8     after BUILD {
9         # Force value build
10         $self->meta->get_attribute('_util')->get_read_method_ref->($self);
11     }
12
13     has _util => (
14         isa => 'Gitalist::Git::Util',
15         lazy => 1,
16         is => 'bare',
17         builder => '_build_util',
18         handles => [qw/
19             run_cmd
20             run_cmd_fh
21             run_cmd_list
22             get_gpp_object
23             gpp
24         /],
25         traits => [qw/ DoNotSerialize /],
26     );
27     method _build_util { confess(shift() . " cannot build _util") }
28 }
29
30 1;
31
32 __END__
33
34 =head1 NAME
35
36 Gitalist::Git::HasUtils - Role for classes with an instance of Gitalist::Git::Util
37
38 =head1 AUTHORS
39
40 See L<Gitalist> for authors.
41
42 =head1 LICENSE
43
44 See L<Gitalist> for the license.
45
46 =cut