1 package Git::PurePerl::NewObject;
3 use MooseX::StrictConstructor;
4 use Moose::Util::TypeConstraints;
5 use namespace::autoclean;
7 enum 'ObjectKind' => qw(commit tree blob tag);
9 has 'kind' => ( is => 'ro', isa => 'ObjectKind', required => 1 );
10 has 'size' => ( is => 'ro', isa => 'Int', required => 0, lazy_build => 1 );
11 has 'content' => ( is => 'rw', isa => 'Str', required => 0, lazy_build => 1 );
12 has 'sha1' => ( is => 'ro', isa => 'Str', required => 0, lazy_build => 1 );
16 my $sha1 = Digest::SHA1->new;
17 $sha1->add( $self->raw );
18 my $sha1_hex = $sha1->hexdigest;
24 return length $self->content;
29 return $self->kind . ' ' . $self->size . "\0" . $self->content;
32 __PACKAGE__->meta->make_immutable;