Skip to content

Commit

Permalink
Merge branch 'store_type_checks'
Browse files Browse the repository at this point in the history
  • Loading branch information
kasei committed Jan 28, 2016
2 parents 88633f0 + 580255e commit 4263638
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/Attean/API/Store.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,20 @@ package Attean::API::Store 0.011 {

package Attean::API::TripleStore 0.011 {
use Moo::Role;
use Scalar::Util qw(blessed);
use namespace::clean;

with 'Attean::API::Store';

requires 'get_triples';

before 'get_triples' => sub {
if (scalar(@_) == 2 and blessed($_[1]) and not($_[1]->does('Attean::API::TermOrVariable'))) {
my $type = ref($_[0]);
die "get_triples called with a single $type argument, but expecting a list of terms/variables";
}
};

sub count_triples {
my $self = shift;
my $iter = $self->get_triples(@_);
Expand Down Expand Up @@ -90,10 +100,20 @@ package Attean::API::TimeCacheableTripleStore 0.011 {

package Attean::API::QuadStore 0.011 {
use Moo::Role;
use Scalar::Util qw(blessed);
use namespace::clean;

with 'Attean::API::Store';

requires 'get_quads';

before 'get_quads' => sub {
if (scalar(@_) == 2 and blessed($_[1]) and not($_[1]->does('Attean::API::TermOrVariable'))) {
my $type = ref($_[0]);
die "get_quads called with a single $type argument, but expecting a list of terms/variables";
}
};

sub count_quads {
my $self = shift;
my $iter = $self->get_quads(@_);
Expand Down

0 comments on commit 4263638

Please sign in to comment.