line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::SingleArg::Meta::Object; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$MooseX::SingleArg::Meta::Object::VERSION = '0.09'; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
14367
|
use Moose::Role; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
20
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
9109
|
use Carp qw( croak ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
405
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
around BUILDARGS => sub{ |
10
|
|
|
|
|
|
|
my $orig = shift; |
11
|
|
|
|
|
|
|
my $class = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $meta = $class->meta(); |
14
|
|
|
|
|
|
|
croak("single_arg() has not been called for $class") if !$meta->has_single_arg(); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $force = $meta->force_single_arg(); |
17
|
|
|
|
|
|
|
croak("$class accepts only one argument") if $force and @_>1; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if (@_==1 and ($force or ref($_[0]) ne 'HASH')) { |
20
|
|
|
|
|
|
|
return $class->$orig( $meta->single_arg() => $_[0] ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return $class->$orig( @_ ); |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |