Skip to content

Commit d90eecb

Browse files
committed
move new User model to the new model location
at the same time make my new download model stub more like existing models
1 parent f609250 commit d90eecb

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

lib/MetaCPAN/API/Model/Download.pm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package MetaCPAN::API::Model::Download;
22

3-
use Mojo::Base -base;
3+
use MetaCPAN::Moose;
44

5-
use Carp ();
5+
use MetaCPAN::Types qw( Object );
66

7-
has es => sub { Carp::croak 'es is required' };
7+
has es => (
8+
is => 'ro',
9+
isa => Object,
10+
handles => { _run_query => 'search', },
11+
required => 1,
12+
);
13+
14+
__PACKAGE__->meta->make_immutable;
815

916
1;
1017

lib/MetaCPAN/Model/User.pm renamed to lib/MetaCPAN/API/Model/User.pm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
package MetaCPAN::Model::User;
1+
package MetaCPAN::API::Model::User;
22

33
use MetaCPAN::Moose;
44

5-
use Log::Contextual qw( :log :dlog );
6-
use MooseX::StrictConstructor;
7-
85
use MetaCPAN::Types qw( Object );
96

107
#use MetaCPAN::Util qw( single_valued_arrayref_to_scalar );
@@ -38,5 +35,7 @@ sub lookup {
3835
return $res->{hits}{hits}[0]{_source};
3936
}
4037

38+
__PACKAGE__->meta->make_immutable;
39+
4140
1;
4241

lib/MetaCPAN/API/Plugin/Model.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use Carp ();
66

77
# Models from the catalyst app
88
use MetaCPAN::Model::Search ();
9-
use MetaCPAN::Model::User ();
109

1110
# New models
11+
use MetaCPAN::API::Model::User ();
1212
use MetaCPAN::API::Model::Download ();
1313

1414
has app => sub { Carp::croak 'app is required' }, weak => 1;
@@ -28,7 +28,7 @@ has search => sub {
2828

2929
has user => sub {
3030
my $self = shift;
31-
return MetaCPAN::Model::User->new( es => $self->app->es );
31+
return MetaCPAN::API::Model::User->new( es => $self->app->es );
3232
};
3333

3434
sub register {

0 commit comments

Comments
 (0)