| 1 | # ABSTRACT: MongoDB plugin for the Dancer micro framework | ||||||||||
| 2 | package Dancer::Plugin::Mongo; | ||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Dancer::Plugin; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use MongoDB 0.38; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | our $VERSION = 0.03; | |||||||||
| 10 | |||||||||||
| 11 | 1 | my $settings = plugin_setting; | |||||||||
| 12 | 1 | my $conn; | |||||||||
| 13 | |||||||||||
| 14 | ## return a connected MongoDB object | ||||||||||
| 15 | 0 | ▶ | register mongo => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | $conn ? $conn : $conn = MongoDB::Connection->new( _slurp_settings() ) ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | |||||||||||
| 19 | 0 | return $conn; | |||||||||
| 20 | 1 | }; | |||||||||
| 21 | |||||||||||
| 22 | 1 | register_plugin; | |||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | sub _slurp_settings { | ||||||||
|
Subroutine
_slurp_settings: not called CC=3 SCAR=24.8
| |||||||||||
| 25 | |||||||||||
| 26 | 0 | my $args = {}; | |||||||||
| 27 | 0 | for (qw/ host port username password w wtimeout auto_reconnect auto_connect | |||||||||
| 28 | timeout db_name query_timeout find_master/) { | ||||||||||
| 29 | 0 | ▶ | if (exists $settings->{$_}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | $args->{$_} = $settings->{$_}; | |||||||||
| 31 | } | ||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | return $args; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | 1 | 1; | |||||||||
| 39 | |||||||||||
| 40 | __END__ | ||||||||||