Data::Hive::Store - a backend storage driver for Data::Hive


Data-Hive documentation Contained in the Data-Hive distribution.

Index


Code Index:

NAME

Top

Data::Hive::Store - a backend storage driver for Data::Hive

VERSION

Top

version 1.008

DESCRIPTION

Top

Data::Hive::Store is a generic interface to a backend store for Data::Hive.

METHODS

Top

All methods are passed at least a 'path' (arrayref of namespace pieces). Store classes exist to operate on the entities found at named paths.

get

  print $store->get(\@path, \%opt);

Return the resource represented by the given path.

set

  $store->set(\@path, $value, \%opt);

Analogous to get.

name

  print $store->name(\@path, \%opt);

Return a store-specific name for the given path. This is primarily useful for stores that may be accessed independently of the hive.

exists

  if ($store->exists(\@path, \%opt)) { ... }

Returns true if the given path exists in the store.

delete

  $store->delete(\@path, \%opt);

Delete the given path from the store. Return the previous value, if any.

keys

  my @keys = $store->keys(\@path, \%opt);

This returns a list of next-level path elements that lead toward existing values. For more information on the expected behavior, see the KEYS method in Data::Hive.

AUTHORS

Top

COPYRIGHT AND LICENSE

Top


Data-Hive documentation Contained in the Data-Hive distribution.

use strict;
use warnings;
package Data::Hive::Store;
BEGIN {
  $Data::Hive::Store::VERSION = '1.008';
}
# ABSTRACT: a backend storage driver for Data::Hive

use Carp ();


BEGIN {
  for my $meth (qw(get set name exists delete keys)) {
    no strict 'refs';
    *$meth = sub { Carp::croak("$_[0] does not implement $meth") };
  }
}

sub save {}

sub save_all {
  my ($self, $path) = @_;

  $self->save;
  for my $key ($self->keys($path)) {
    $self->save_all([ @$path, $key ]);
  }

  return;
}

sub delete_all {
  my ($self, $path) = @_;

  $self->delete($path);
  for my $key ($self->keys($path)) {
    $self->delete_all([ @$path, $key ]);
  }

  return;
}

1;

__END__