MXNet/Gluon/Mouse.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 3 SCAR 16.7
CC
3
Cov
0%
has
12.0
init_meta
2.0
BEGIN
2.0
CRAP 5.3
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17  
18 package AI::MXNet::Gluon::Mouse;
19 use strict;
20 use warnings;
21 use Mouse;
22 use Mouse::Exporter;
23 no Mouse;
24  
25 Mouse::Exporter->setup_import_methods(
26 as_is => [
27 'has',
28 \&Mouse::extends,
29 \&Mouse::with,
30 \&Mouse::before,
31 \&Mouse::after,
32 \&Mouse::around,
33 \&Mouse::override,
34 \&Mouse::super,
35 \&Mouse::augment,
36 \&Mouse::inner,
37 \&Scalar::Util::blessed,
38 \&Carp::confess
39 ]
40 );
41  
42 sub init_meta { return Mouse::init_meta(@_) }
43 sub has
44 {
45 my $name = shift;
46 my %args = @_;
47 my $caller = delete $args{caller} // caller;
48 my $meta = $caller->meta;
49  
50 $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )})
51 if @_ % 2; # odd number of arguments
52  
53 for my $n (ref($name) ? @{$name} : $name){
54 $meta->add_attribute(
55 $n,
56 trigger => sub { my $self = shift; $self->__setattr__($n, @_); },
57 %args
58 );
59 }
60 return;
61 }
62  
63 1;