| 1 | package Dancer::App; | ||||||||||||||||||||||||||||
| 2 | 194 | our $AUTHORITY = 'cpan:SUKRIA'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: Base application class for Dancer. | ||||||||||||||||||||||||||||
| 4 | 194 | $Dancer::App::VERSION = '1.3522'; | |||||||||||||||||||||||||||
| 5 | 194 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 194 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 194 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 194 | ▶ | use base 'Dancer::Object'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 194 | ▶ | use Dancer::Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 194 | ▶ | use Dancer::ModuleLoader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 194 | ▶ | use Dancer::Route::Registry; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 194 | ▶ | use Dancer::Logger; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 194 | ▶ | use Dancer::Exception qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 194 | ▶ | use Dancer::Deprecation; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 194 | Dancer::App->attributes(qw(name app_prefix prefix registry settings on_lexical_prefix)); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # singleton that saves any app created, we want unicity for app names | ||||||||||||||||||||||||||||
| 20 | 194 | my $_apps = {}; | |||||||||||||||||||||||||||
| 21 | 1951 | ▶ | sub applications { values %$_apps } | ||||||||||||||||||||||||||
|
Subroutine
applications: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1444 | ▶ | sub app_exists { | ||||||||||||||||||||||||||
|
Subroutine
app_exists: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 1444 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||
| 25 | 1444 | grep { $_ eq $name } keys %$_apps; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 16 | ▶ | sub set_running_app { | ||||||||||||||||||||||||||
|
Subroutine
set_running_app: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 16 | my ($self, $name) = @_; | |||||||||||||||||||||||||||
| 30 | 16 | my $app = Dancer::App->get($name); | |||||||||||||||||||||||||||
| 31 | 16 | ▶ | $app = Dancer::App->new(name => $name) unless defined $app; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 16 | Dancer::App->current($app); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | sub set_app_prefix { | ||||||||||||||||||||||||||
|
Subroutine
set_app_prefix: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 1 | my ($self, $prefix) = @_; | |||||||||||||||||||||||||||
| 37 | 1 | $self->app_prefix($prefix); | |||||||||||||||||||||||||||
| 38 | 1 | $self->prefix($prefix); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 3 | ▶ | sub get_prefix { | ||||||||||||||||||||||||||
|
Subroutine
get_prefix: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | # return the current prefix (if undefined, return an empty string) | ||||||||||||||||||||||||||||
| 43 | 3 | ▶ | return Dancer::App->current->prefix || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
'Dancer::App'->current->prefix || ''
MC/DC100%1/1
'Dancer::App'->current->prefix || ''
'Dancer::App'->current->prefix
Truth table100%2/2
A
A= 'Dancer::App'->current->prefix
| |||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 15 | ▶ | sub incr_lexical_prefix { | ||||||||||||||||||||||||||
|
Subroutine
incr_lexical_prefix: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | 194 | ▶ | no warnings; # for undefined | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 15 | $_[0]->on_lexical_prefix( $_[0]->on_lexical_prefix + 1 ); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 15 | ▶ | sub dec_lexical_prefix { | ||||||||||||||||||||||||||
|
Subroutine
dec_lexical_prefix: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 15 | $_[0]->on_lexical_prefix( $_[0]->on_lexical_prefix - 1 ); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 29 | ▶ | sub set_prefix { | ||||||||||||||||||||||||||
|
Subroutine
set_prefix: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 29 | my ($self, $prefix, $cb) = @_; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 29 | ▶ | undef $prefix if defined($prefix) and $prefix eq "/"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $prefix and $prefix eq "/"
MC/DC100%2/2
defined $prefix and $prefix eq "/"
defined $prefix
$prefix eq "/"
Truth table100%3/3
A and B
A= defined $prefixB= $prefix eq "/"
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 29 | ▶ | raise core_app => "not a valid prefix: `$prefix', must start with a /" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $prefix and not $prefix =~ m[^/]
MC/DC100%2/2
defined $prefix and not $prefix =~ m[^/]
defined $prefix
not $prefix =~ m[^/]
Truth table100%3/3
A and not(B)
A= defined $prefixB= not $prefix =~ m[^/]
| |||||||||||||||||||||||||||||
| 61 | if defined($prefix) && $prefix !~ /^\//; | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 28 | ▶ | my $app_prefix = defined $self->app_prefix ? $self->app_prefix : ""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 28 | my $previous = Dancer::App->current->prefix; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 28 | ▶ | $prefix ||= ""; | ||||||||||||||||||||||||||
|
Condition100%2/2
$prefix ||= ""
MC/DC100%1/1
$prefix ||= ""
$prefix
Truth table100%2/2
A
A= $prefix
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 28 | ▶ | if (Dancer::App->current->on_lexical_prefix) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 10 | Dancer::App->current->prefix($previous.$prefix); | |||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||
| 71 | 18 | Dancer::App->current->prefix($app_prefix.$prefix); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 28 | ▶ | if (ref($cb) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 15 | Dancer::App->current->incr_lexical_prefix; | |||||||||||||||||||||||||||
| 76 | 15 | eval { $cb->() }; | |||||||||||||||||||||||||||
| 77 | 15 | my $e = $@; | |||||||||||||||||||||||||||
| 78 | 15 | Dancer::App->current->dec_lexical_prefix; | |||||||||||||||||||||||||||
| 79 | 15 | Dancer::App->current->prefix($previous); | |||||||||||||||||||||||||||
| 80 | 15 | ▶ | die $e if $e; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 28 | return 1; # prefix may have been set to undef | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 2 | ▶ | sub routes { | ||||||||||||||||||||||||||
|
Subroutine
routes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 2 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 87 | 2 | map { $_->pattern } @{$self->registry->{'routes'}{$method}}; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub reload_apps { | ||||||||||||||||||||||||||
|
Subroutine
reload_apps: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | Dancer::Deprecation->deprecated( | |||||||||||||||||||||||||||
| 94 | feature => 'auto_reload', | ||||||||||||||||||||||||||||
| 95 | reason => 'use plackup -r instead', | ||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | my @missing_modules = grep { not Dancer::ModuleLoader->load($_) } | |||||||||||||||||||||||||||
| 99 | qw(Module::Refresh Clone); | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if (not @missing_modules) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # saving apps & purging app registries | ||||||||||||||||||||||||||||
| 104 | 0 | my $orig_apps = {}; | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | while (my ($name, $app) = each %$_apps) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | $orig_apps->{$name} = $app->clone; | |||||||||||||||||||||||||||
| 107 | 0 | $app->registry->init(); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | # reloading changed modules, getting apps reloaded | ||||||||||||||||||||||||||||
| 111 | 0 | Module::Refresh->refresh; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | # make sure old apps that didn't get reloaded are kept | ||||||||||||||||||||||||||||
| 114 | 0 | ▶ | while (my ($name, $app) = each %$orig_apps) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $_apps->{$name} = $app unless defined $_apps->{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $_apps->{$name} = $app if $_apps->{$name}->registry->is_empty; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||
| 121 | 0 | carp "Modules required for auto_reload are missing. Install modules" | |||||||||||||||||||||||||||
| 122 | . " [@missing_modules] or unset 'auto_reload' in your config file."; | ||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 585 | ▶ | sub find_route_through_apps { | ||||||||||||||||||||||||||
|
Subroutine
find_route_through_apps: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | 585 | my ($class, $request) = @_; | |||||||||||||||||||||||||||
| 128 | 585 | for my $app (Dancer::App->current, Dancer::App->applications) { | |||||||||||||||||||||||||||
| 129 | 623 | my $route = $app->find_route($request); | |||||||||||||||||||||||||||
| 130 | 623 | ▶ | if ($route) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 558 | Dancer::App->current($route->app); | |||||||||||||||||||||||||||
| 132 | 558 | return $route; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 65 | ▶ | return $route if $route; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 27 | return; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | # instance | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 623 | ▶ | sub find_route { | ||||||||||||||||||||||||||
|
Subroutine
find_route: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 142 | 623 | my ($self, $request) = @_; | |||||||||||||||||||||||||||
| 143 | 623 | my $method = lc($request->method); | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | # if route cache is enabled, we check if we handled this path before | ||||||||||||||||||||||||||||
| 146 | 623 | ▶ | if (Dancer::Config::setting('route_cache')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 84 | my $route = Dancer::Route::Cache->get->route_from_path($method, | |||||||||||||||||||||||||||
| 148 | $request->path_info, $self->name); | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | # NOTE maybe we should cache the match data as well | ||||||||||||||||||||||||||||
| 151 | 84 | ▶ | if ($route) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 36 | $route->match($request); | |||||||||||||||||||||||||||
| 153 | 36 | return $route; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 587 | my @routes = @{$self->registry->routes($method)}; | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 587 | for my $r (@routes) { | |||||||||||||||||||||||||||
| 160 | 1552 | my $match = $r->match($request); | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 1552 | ▶ | if ($match) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 536 | ▶ | next if $r->has_options && (not $r->validate_options($request)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$r->has_options and not $r->validate_options($request)
MC/DC100%2/2
$r->has_options and not $r->validate_options($request)
$r->has_options
not $r->validate_options($request)
Truth table100%3/3
A and not(B)
A= $r->has_optionsB= not $r->validate_options($request)
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | # if we have a route cache, store the result | ||||||||||||||||||||||||||||
| 166 | 522 | ▶ | if (Dancer::Config::setting('route_cache')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 48 | Dancer::Route::Cache->get->store_path($method, | |||||||||||||||||||||||||||
| 168 | $request->path_info => $r, $self->name); | ||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 522 | return $r; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | 65 | return; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 116 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 116 | my ($self) = @_; | |||||||||||||||||||||||||||
| 179 | 116 | ▶ | $self->name('main') unless defined $self->name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | raise core_app => "an app named '" . $self->name . "' already exists" | ||||||||||||||||||||||||||||
| 182 | 116 | ▶ | if exists $_apps->{$self->name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | # default values for properties | ||||||||||||||||||||||||||||
| 185 | 115 | $self->settings({}); | |||||||||||||||||||||||||||
| 186 | 115 | $self->init_registry(); | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 115 | $_apps->{$self->name} = $self; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 115 | ▶ | sub init_registry { | ||||||||||||||||||||||||||
|
Subroutine
init_registry: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 192 | 115 | my ($self, $reg) = @_; | |||||||||||||||||||||||||||
| 193 | 115 | ▶ | $self->registry($reg || Dancer::Route::Registry->new); | ||||||||||||||||||||||||||
|
Condition33%1/3
$reg || 'Dancer::Route::Registry'->new
MC/DC0%0/2
$reg || 'Dancer::Route::Registry'->new
$reg
'Dancer::Route::Registry'->new
Truth table33%1/3
A || B
A= $regB= 'Dancer::Route::Registry'->new
| |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | # singleton that saves the current active Dancer::App object | ||||||||||||||||||||||||||||
| 198 | 194 | my $_current; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 8211 | ▶ | sub current { | ||||||||||||||||||||||||||
|
Subroutine
current: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 201 | 8211 | my ($class, $app) = @_; | |||||||||||||||||||||||||||
| 202 | 8211 | ▶ | return $_current = $app if defined $app; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 7155 | ▶ | if (not defined $_current) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 99 | ▶ | $_current = Dancer::App->get('main') || Dancer::App->new(); | ||||||||||||||||||||||||||
|
Condition66%2/3
'Dancer::App'->get('main') || 'Dancer::App'->new
MC/DC0%0/2
'Dancer::App'->get('main') || 'Dancer::App'->new
'Dancer::App'->get('main')
'Dancer::App'->new
Truth table66%2/3
A || B
A= 'Dancer::App'->get('main')B= 'Dancer::App'->new
| |||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 7155 | return $_current; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 774 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 212 | 774 | my ($class, $name) = @_; | |||||||||||||||||||||||||||
| 213 | 774 | $_apps->{$name}; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 2397 | ▶ | sub setting { | ||||||||||||||||||||||||||
|
Subroutine
setting: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 217 | 2397 | my $self = shift; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 2397 | ▶ | if ($self->name eq 'main') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 2255 | ▶ | return (@_ > 1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | ? Dancer::Config::setting( @_ ) | ||||||||||||||||||||||||||||
| 222 | : Dancer::Config::setting( $_[0] ); | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 142 | ▶ | if (@_ > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 38 | $self->_set_settings(@_) | |||||||||||||||||||||||||||
| 227 | } else { | ||||||||||||||||||||||||||||
| 228 | 104 | my $name = shift; | |||||||||||||||||||||||||||
| 229 | 104 | ▶ | exists($self->settings->{$name}) ? $self->settings->{$name} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | : Dancer::Config::setting($name); | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 38 | ▶ | sub _set_settings { | ||||||||||||||||||||||||||
|
Subroutine
_set_settings: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 235 | 38 | my $self = shift; | |||||||||||||||||||||||||||
| 236 | 38 | ▶ | die "Odd number of elements in set" unless @_ % 2 == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 38 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 38 | my $name = shift; | |||||||||||||||||||||||||||
| 239 | 38 | my $value = shift; | |||||||||||||||||||||||||||
| 240 | 38 | $self->settings->{$name} = | |||||||||||||||||||||||||||
| 241 | Dancer::Config->normalize_setting($name => $value); | ||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 194 | 1; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | __END__ | ||||||||||||||||||||||||||||