File Coverage

blib/lib/Whelk/Schema/Definition/Number.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 26 26 100.0


line stmt bran cond sub pod time code
1             package Whelk::Schema::Definition::Number;
2             $Whelk::Schema::Definition::Number::VERSION = '1.04';
3 21     21   14117 use Whelk::StrictBase 'Whelk::Schema::Definition::_Scalar';
  21         49  
  21         182  
4 21     21   171 use Scalar::Util qw(looks_like_number);
  21         57  
  21         6524  
5              
6             sub openapi_dump
7             {
8 13     13 1 51 my ($self, $openapi_obj, %hints) = @_;
9              
10 13         46 my $res = $self->SUPER::openapi_dump($openapi_obj, %hints);
11 13         48 $res->{type} = 'number';
12              
13 13         36 return $res;
14             }
15              
16             sub _inhale
17             {
18 88     88   210 my ($self, $value) = @_;
19              
20 88         320 my $inhaled = $self->SUPER::_inhale($value);
21 88 100       259 return $inhaled if defined $inhaled;
22 85 100       412 return 'number' unless looks_like_number($value);
23 75         296 return $self->_inhale_extra_rules($value);
24             }
25              
26             sub _exhale
27             {
28 19     19   81 return 0 + pop();
29             }
30              
31             1;
32