Skip to content

Commit

Permalink
Storage role splitted into storage and storage_class
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Melo <melo@simplicidade.org>
  • Loading branch information
melo committed Aug 13, 2012
1 parent a135af3 commit d31f97e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/Config/Connie/Storage.pm
@@ -1,10 +1,19 @@
package Config::Connie::Storage;

use Moo::Role;
use Carp ();
use namespace::autoclean;

requires 'build_storage';
has 'storage' => (is => 'lazy', builder => 'build_storage', handles => ['check_for_updates']);
has 'storage_class' => (is => 'lazy', builder => 'build_storage_class');

sub build_storage {
my ($self) = @_;

return $self->storage_class->new(instance => $self);
}

sub build_storage_class { Carp::confess "Class '" . ref(shift) . "' requires a build_storage_class method" }

has 'storage' => (is => 'ro', builder => 'build_storage', handles => ['check_for_updates']);

1;
2 changes: 1 addition & 1 deletion t/tlib/T/Storage/Config.pm
Expand Up @@ -14,6 +14,6 @@ with

sub default_config_id {'defaults_id'}

sub build_storage { Config::Connie::Storage::Local->new(instance => shift) }
sub build_storage_class {'Config::Connie::Storage::Local'}

1;

0 comments on commit d31f97e

Please sign in to comment.