We do actually really want per context instances of the model. Otherwise we grab...
[catagits/Gitalist.git] / lib / Gitalist / Model / GitRepos.pm
index 5e0bddb..e780f5b 100644 (file)
@@ -2,12 +2,24 @@ package Gitalist::Model::GitRepos;
 
 use Moose;
 use Gitalist::Git::Repo;
+use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
 use namespace::autoclean;
 
-sub COMPONENT {
-    my ($class, $app, $config) = @_;
+extends 'Catalyst::Model';
 
-    Gitalist::Git::Repo->new($config);
+with 'Catalyst::Component::InstancePerContext';
+
+has repo_dir => (
+    isa => NonEmptySimpleStr,
+    is => 'ro',
+    required => 1,
+);
+
+sub build_per_context_instance {
+    my ($self, $app) = @_;
+
+    Gitalist::Git::Repo->new(repo_dir => $self->repo_dir);
 }
 
 __PACKAGE__->meta->make_immutable;
+