This repository has been archived by the owner on Mar 21, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It will allow to store SCK data on other DB engine than Redis. Next step will be MongoDB
- Loading branch information
geistteufel
committed
Apr 13, 2012
1 parent
c1eba26
commit 0aa03d9
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package Celogeek::SCK::Store; | ||
|
||
# ABSTRACT: handle storage of SCK website | ||
|
||
use strict; | ||
use warnings; | ||
# VERSION | ||
use Moo; | ||
|
||
has 'engine' => ( | ||
is => 'ro', | ||
isa => sub { | ||
die "not a valid engine" unless $_[0] =~ /^redis$/; | ||
}, | ||
required => 1, | ||
); | ||
|
||
has 'connection' => ( | ||
is => 'ro', | ||
required => 1, | ||
); | ||
|
||
sub BUILD { | ||
my $self = shift; | ||
my $store = __PACKAGE__.'::'.ucfirst($self->engine); | ||
with $store; | ||
with __PACKAGE__.'::Base'; | ||
$self->validate_connection(); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package Celogeek::SCK::Store::Base; | ||
|
||
# ABSTRACT: Empty store, to force implementation of method | ||
|
||
use strict; | ||
use warnings; | ||
# VERSION | ||
|
||
use Moo::Role; | ||
|
||
sub _die { | ||
my $self = shift; | ||
my $store_class = substr(__PACKAGE__,0,-length('Base')).ucfirst($self->engine); | ||
my $func = substr((caller(1))[3], length(__PACKAGE__) + 2); | ||
die "${store_class}::${func} need to be implemented"; | ||
} | ||
|
||
#method need to be implemented | ||
for my $meth (qw/validate_connection set_config get_config/) { | ||
eval <<EOF | ||
sub $meth { shift->_die } | ||
EOF | ||
; | ||
} | ||
|
||
1; |