line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
41
|
use strict; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
356
|
|
2
|
10
|
|
|
10
|
|
37
|
use warnings; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
313
|
|
3
|
|
|
|
|
|
|
package Dancer::Plugin::CORS::Sharing; |
4
|
|
|
|
|
|
|
# ABSTRACT: Helper class for I method |
5
|
|
|
|
|
|
|
|
6
|
10
|
|
|
10
|
|
39
|
use Carp; |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
511
|
|
7
|
10
|
|
|
10
|
|
38
|
use Scalar::Util qw(blessed); |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
2917
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.13'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new($%) { |
13
|
2
|
|
|
2
|
1
|
3
|
my $class = shift; |
14
|
2
|
|
|
|
|
6
|
my %options = (rules => []); |
15
|
2
|
100
|
66
|
|
|
19
|
if (blessed $class and $class->isa(__PACKAGE__)) { |
16
|
1
|
|
|
|
|
36
|
%options = (%$class, %options); |
17
|
|
|
|
|
|
|
} |
18
|
2
|
|
|
|
|
10
|
%options = (%options, @_); |
19
|
2
|
50
|
|
|
|
7
|
croak "sharing->new should be called inside a dancer app, not outside" unless exists $options{_add_rule}; |
20
|
2
|
|
66
|
|
|
17
|
return bless \%options => ref $class || $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub rule($%) { |
25
|
3
|
|
|
3
|
1
|
11
|
my ($self, %options) = @_; |
26
|
3
|
|
|
|
|
3
|
push @{$self->{rules}} => \%options; |
|
3
|
|
|
|
|
5
|
|
27
|
3
|
|
|
|
|
5
|
$self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add { |
32
|
4
|
|
|
4
|
1
|
906
|
my ($self, @routes) = @_; |
33
|
4
|
|
|
|
|
7
|
foreach my $routes (@routes) { |
34
|
5
|
50
|
|
|
|
16
|
$routes = [ $routes ] unless ref $routes eq 'ARRAY'; |
35
|
5
|
|
|
|
|
7
|
foreach my $route (@$routes) { |
36
|
5
|
|
|
|
|
4
|
foreach my $options (@{$self->{rules}}) { |
|
5
|
|
|
|
|
9
|
|
37
|
7
|
|
|
|
|
21
|
$self->{_add_rule}->($route, %$options); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
4
|
|
|
|
|
8
|
$self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub clear { |
46
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
47
|
1
|
|
|
|
|
2
|
$self->{rules} = []; |
48
|
1
|
|
|
|
|
4
|
$self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |