| 1 | package Mojolicious::Plugin::Mango; | ||||||||||||
| 2 | 2 | ▶ | use Modern::Perl; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use Mango; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 2 | our $VERSION = '0.0.2'; # VERSION | |||||||||||
| 8 | # ABSTRACT: provide mango helpers to Mojolicious | ||||||||||||
| 9 | |||||||||||||
| 10 | 1 | ▶ | sub register { | ||||||||||
|
Subroutine
register: called CC=8 SCAR=22.7
Pod
documented
| |||||||||||||
| 11 | 1 | my $self = shift; | |||||||||||
| 12 | 1 | my $app = shift; | |||||||||||
| 13 | 1 | ▶ | my $conf = shift || {}; | ||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 14 | 1 | ▶ | $conf->{helper} ||= 'db'; | ||||||||||
|
Condition50%1/2
$conf->{"helper"} ||= "db"
MC/DC0%0/1
$conf->{"helper"} ||= "db"
$conf->{"helper"}
Truth table50%1/2
A
A= $conf->{"helper"}
| |||||||||||||
| 15 | 1 | ▶ | $conf->{default_db} ||= 'test'; | ||||||||||
|
Condition50%1/2
$conf->{"default_db"} ||= "test"
MC/DC0%0/1
$conf->{"default_db"} ||= "test"
$conf->{"default_db"}
Truth table50%1/2
A
A= $conf->{"default_db"}
| |||||||||||||
| 16 | 1 | ▶ | $app->attr('_mango' => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||
| 17 | 1 | my $m = Mango->new($conf->{mango}); | |||||||||||
| 18 | 1 | $m->default_db($conf->{default_db}); | |||||||||||
| 19 | 1 | ▶ | $m->hosts($conf->{hosts}) if $conf->{hosts}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | 1 | $m; | |||||||||||
| 21 | } | ||||||||||||
| 22 | 1 | ); | |||||||||||
| 23 | 1 | ▶ | $app->helper('mango' => sub { shift; Mango->new(@_) }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | 3 | ▶ | $app->helper($conf->{helper} => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 25 | 3 | my $self = shift; | |||||||||||
| 26 | 3 | return $self->app->_mango->db(@_); | |||||||||||
| 27 | } | ||||||||||||
| 28 | 1 | ); | |||||||||||
| 29 | 0 | ▶ | $app->helper('hosts' => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 30 | 0 | my $self = shift; | |||||||||||
| 31 | 0 | return $self->app->_mango->hosts(@_); | |||||||||||
| 32 | 1 | }); | |||||||||||
| 33 | 0 | ▶ | $app->helper('default_db' => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||
| 35 | 0 | return $self->app->_mango->default_db(@_); | |||||||||||
| 36 | 1 | }); | |||||||||||
| 37 | 1 | ▶ | $app->helper('coll' => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 38 | 1 | my $self = shift; | |||||||||||
| 39 | 1 | return $self->app->_mango->db->collection(@_); | |||||||||||
| 40 | 1 | }); | |||||||||||
| 41 | 1 | for my $helper (qw/get_more kill_cursors query/) { | |||||||||||
| 42 | 3 | ▶ | next if (defined ($conf->{"no_$helper"})); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 0 | ▶ | $app->helper($helper => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 44 | 0 | my $self = shift; | |||||||||||
| 45 | 0 | $self->app->_mango->$helper(@_); | |||||||||||
| 46 | }) | ||||||||||||
| 47 | 3 | } | |||||||||||
| 48 | 1 | for my $helper (qw/collection collection_names command dereference gridfs stats/) { | |||||||||||
| 49 | 6 | ▶ | next if (defined ($conf->{"no_$helper"})); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 50 | 0 | ▶ | $app->helper($helper => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 51 | 0 | my $self = shift; | |||||||||||
| 52 | 0 | $self->app->_mango->db->$helper(@_); | |||||||||||
| 53 | }) | ||||||||||||
| 54 | 6 | } | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | 2 | 1; | |||||||||||
| 58 | |||||||||||||
| 59 | __END__ | ||||||||||||