File Coverage

blib/lib/SilverGoldBull/API/Item.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package SilverGoldBull::API::Item;
2              
3 1     1   991 use strict;
  1         2  
  1         28  
4 1     1   4 use warnings;
  1         1  
  1         22  
5              
6 1     1   168 use Mouse;
  0            
  0            
7             with qw(SilverGoldBull::API::CommonMethodsRole);
8              
9             has 'id' => ( is => 'rw', isa => 'Str', required => 1 );
10             has 'bid_price' => ( is => 'rw', isa => 'Num', required => 0 );
11             has 'qty' => ( is => 'rw', isa => 'Int', required => 1 );
12              
13             sub to_hashref {
14             my ($self) = @_;
15             my $hashref = {};
16             for my $field (qw(id bid_price qty)) {
17             if (defined $self->{$field}) {
18             $hashref->{$field} = $self->{$field};
19             }
20             }
21            
22             return $hashref;
23             }
24              
25             1;