Git::Database::Role::Backend - Abstract role for a Git database backend
version 0.009
package MyGitBackend; use Moo; use namespace::clean; with 'Git::Database::Role::Backend'; 1;
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.
Git::Database::Role::Backend
The store that will store and retrieve data from the Git repository.
There is a has_store predicate method for this attribute.
has_store
# 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.
$object->digest
The role provides a Perl implementation for it, but most backends will want to override it for performance reasons.
# 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 dies if kind is unknown or not provided.
kind
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.
Philippe Bruhat (BooK) <book@cpan.org>
Copyright 2016 Philippe Bruhat (BooK), all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Git::Database, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Git::Database
CPAN shell
perl -MCPAN -e shell install Git::Database
For more information on module installation, please visit the detailed CPAN module installation guide.