Created
October 27, 2011 21:01
-
-
Save broquaint/1320861 to your computer and use it in GitHub Desktop.
build_per_context_instance loading a model from command-line args
This file contains hidden or 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
sub build_per_context_instance { | |
my ($self, $app) = @_; | |
my %args = (export_ok => $self->export_ok || ''); | |
my $class; | |
# Try to get the model from command-line args first. | |
GetOptionsFromArray($app->run_options->{extra_argv}, 'model=s' => \$class); | |
if($class) { | |
Class::MOP::load_class($class) unless Class::MOP::is_class_loaded($class); | |
# %args = ??? | |
} elsif($self->whitelist && -f $self->whitelist) { | |
$class = 'Gitalist::Git::CollectionOfRepositories::FromDirectory::WhiteList'; | |
$args{repo_dir} = $self->repo_dir; | |
$args{whitelist} = $self->whitelist; | |
} elsif ($self->_repos_count && !$self->search_recursively) { | |
$class = 'Gitalist::Git::CollectionOfRepositories::FromListOfDirectories'; | |
$args{repos} = $self->repos; | |
} elsif($self->search_recursively) { | |
$class = 'Gitalist::Git::CollectionOfRepositories::FromDirectoryRecursive'; | |
$args{repo_dir} = $self->repo_dir; | |
} else { | |
$class = 'Gitalist::Git::CollectionOfRepositories::FromDirectory'; | |
$args{repo_dir} = $self->repo_dir; | |
} | |
$app->log->debug("Using '$class' for the CollectionOfRepos model instance."); | |
return $class->new(%args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment