NAME

Git::Database::Role::Object - Role for objects from the Git object database

VERSION

version 0.012

SYNOPSIS

    package Git::Database::Object::Blob;

    use Moo;

    with 'Git::Database::Role::Object';

    sub kind { 'blob' }

    1;

DESCRIPTION

Git::Database::Role::Object provides the generic behaviour for all Git::Database objects obtained from or stored into the Git object database.

When creating a new object meant to be added to the Git object database (via backend), only the "content" attribute is actually required.

New objects are typically created via Git::Database::Role::ObjectReader's get_object method, rather than by calling new directly. This is when the object data is fetched from the Git object database.

ATTRIBUTES

The content, size and digest attribute are lazy, and can be computed from the others: size from content, content from digest (if the object exists in the backend store), and digest from content. All attributes have a predicate method.

Additional attributes in some classes may add other ways to compute the content.

Creating a new object with inconsistent kind, size, content and digest attributes can only end in tears. This is also true for additional attributes such as directory_entries, commit_info, and tag_info.

For now, as soon as the "content" of a Git::Database::Role::Object is needed, it is fully loaded in memory.

backend

A Git::Database::Role::Backend from which the object comes from (or will be stored into). It is typically used by the attribute builders.

If none is provided, a Git::Database::Backend::None is used, which is only able to compute the digest.

content

The object's actual content.

size

The size (in bytes) of the object content.

digest

The SHA-1 digest of the object, as computed by Git.

If set at creation time, it is internally converted to lowercase.

METHODS

as_string

Return a string representation of the content.

By default, this is the same as content(), but some classes may override it.

REQUIRED METHODS

kind

Returns the object "kind".

In Git, this is one of blob, tree, commit, and tag.

SEE ALSO

Git::Database::Object::Blob, Git::Database::Object::Tree, Git::Database::Object::Commit, Git::Database::Object::Tag.

AUTHOR

Philippe Bruhat (BooK) <book@cpan.org>.

COPYRIGHT

Copyright 2013-2016 Philippe Bruhat (BooK), all rights reserved.

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.