Skip to content

Commit 80c1370

Browse files
committed
Add the stub of a download model
This will hold the find_download_url query as we move it from the Catalyst model which is aparently too bloated to want to save directly. This will be the paradigm for new models.
1 parent 2bc8c81 commit 80c1370

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

lib/MetaCPAN/API/Model/Download.pm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package MetaCPAN::API::Model::Download;
2+
3+
use Mojo::Base -base;
4+
5+
use Carp ();
6+
7+
has es => sub { Carp::croak 'es is required' };
8+
9+
1;
10+

lib/MetaCPAN/API/Plugin/Model.pm

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@ package MetaCPAN::API::Plugin::Model;
22

33
use Mojo::Base 'Mojolicious::Plugin';
44

5-
use Carp ();
5+
use Carp ();
6+
7+
# Models from the catalyst app
68
use MetaCPAN::Model::Search ();
79
use MetaCPAN::Model::User ();
810

11+
# New models
12+
use MetaCPAN::API::Model::Download ();
13+
914
has app => sub { Carp::croak 'app is required' }, weak => 1;
1015

16+
has download => sub {
17+
my $self = shift;
18+
return MetaCPAN::API::Model::Download->new( es => $self->app->es );
19+
};
20+
1121
has search => sub {
1222
my $self = shift;
1323
return MetaCPAN::Model::Search->new(
@@ -26,8 +36,9 @@ sub register {
2636
$plugin->app($app);
2737

2838
# cached models
29-
$app->helper( 'model.search' => sub { $plugin->search } );
30-
$app->helper( 'model.user' => sub { $plugin->user } );
39+
$app->helper( 'model.download' => sub { $plugin->download } );
40+
$app->helper( 'model.search' => sub { $plugin->search } );
41+
$app->helper( 'model.user' => sub { $plugin->user } );
3142
}
3243

3344
1;

0 commit comments

Comments
 (0)