File Coverage

blib/lib/Mojolicious/Plugin/NamedHelpers.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition 2 3 66.6
subroutine 4 4 100.0
pod 1 1 100.0
total 18 19 94.7


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::NamedHelpers;
2 2     2   1112 use Mojo::Base 'Mojolicious::Plugin';
  2         4  
  2         13  
3 2     2   327 use Sub::Util qw(set_subname);
  2         11  
  2         335  
4              
5             our $VERSION = '0.03';
6              
7             sub register {
8 2     2 1 68 my ($self, $app, $arg) = @_;
9 2   66     13 $arg->{namespace} //= ref($app);
10             $app->helper(
11             named_helper => sub {
12 2     2   358 my ($c, $name, $sub) = @_;
13 2         8 $c->app->helper($name => set_subname "$arg->{namespace}::$name", $sub);
14             }
15 2         16 );
16             }
17              
18             1;
19             __END__