View on
MetaCPAN
Philippe Bruhat (BooK) > Git-Database-0.007 > Git::Database::Role::Backend

Download:
Git-Database-0.007.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.007   Source   Latest Release: Git-Database-0.010

NAME ^

Git::Database::Role::Backend - Abstract role for a Git database backend

VERSION ^

version 0.007

SYNOPSIS ^

    package MyGitBackend;

    use Moo;
    use namespace::clean;

    with 'Git::Database::Role::Backend';

    1;

DESCRIPTION ^

The Git::Database::Role::Backend role encapsulate code for the user-facing store objects. To be usable as a backend, a class must at least do this role.

REQUIRED ATTRIBUTES ^

store

The store that will store and retrieve data from the Git repository.

There is a has_store predicate method for this attribute.

METHODS ^

hash_object

    # the empty tree
    my $tree = Git::Database::Object::Tree->new( content => '' );
    
    # 4b825dc642cb6eb9a060e54bf8d69288fbee4904
    my $digest = $backend->hash_object( $tree );

Compute and return the SHA-1 digest for the given object.

May be called from the digest builder for one of the object classes (Git::Database::Object::Blob, Git::Database::Object::Tree, Git::Database::Object::Commit, Git::Database::Object::Tag), so the implementation should not try to shortcut and call $object->digest.

The role provides a Perl implementation for it, but most backends will want to override it for performance reasons.

create_object

    # argument is a HASH reference
    my $object = $store->create_object( \%attr );

    # arguments is a list of pairs
    my $object = $store->create_object( %attr );

Return an object instance of an object doing the Git::Database::Role::Object role, or undef if kind is unknown or not provided.

This method assumes the provided attribute values are consistent for the object kind. Behaviour is undefined if the various attributes are not internally consistent. (E.g. if the size does not match the content.)

Note: this method creates new objects, but does not store them in the underlying Git datatase. Do save them in the database, use "put_object" in Git::Database::Role::Object::Writer.

AUTHOR ^

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

COPYRIGHT ^

Copyright 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.

syntax highlighting: