Skip to content

Commit

Permalink
add ESQuery catalyst model
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Jan 14, 2025
1 parent 8368aec commit e4f72f4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/MetaCPAN/Server/Model/ESQuery.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package MetaCPAN::Server::Model::ESQuery;

use Moose;

use MetaCPAN::Query ();

extends 'Catalyst::Model';

has es => (
is => 'ro',
writer => '_set_es',
);

has _esx_query => (
is => 'ro',
lazy => 1,
default => sub {
my $self = shift;
MetaCPAN::Query->new( es => $self->es );
},
);

sub ACCEPT_CONTEXT {
my ( $self, $c ) = @_;
if ( !$self->es ) {
$self->_set_es( $c->model('ES') );
}
return $self->_esx_query;
}

1;

0 comments on commit e4f72f4

Please sign in to comment.