File Coverage

lib/MouseX/AttributeHelpers/Collection/Bag.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 12 12 100.0
pod 2 2 100.0
total 35 35 100.0


line stmt bran cond sub pod time code
1             package MouseX::AttributeHelpers::Collection::Bag;
2 5     37   6843 use Mouse;
  5         10  
  5         38  
3 5     5   1752 use Mouse::Util::TypeConstraints;
  5         9  
  5         136  
4 5     5   2871 use MouseX::AttributeHelpers::Collection::ImmutableHash;
  5         220  
  5         1746  
5              
6             extends 'MouseX::AttributeHelpers::Base';
7              
8             has '+method_constructors' => (
9             default => sub {
10             my $attr = MouseX::AttributeHelpers::Collection::ImmutableHash->meta->get_attribute('method_constructors');
11             return +{
12             %{ $attr->default->() }, # apply MouseX::AttributeHelpers::Collection::ImmutableHash
13              
14             add => sub {
15             my ($attr, $name) = @_;
16 84     84   1291 return sub { $_[0]->$name()->{$_[1]}++ };
        2      
17             },
18             delete => sub {
19             my ($attr, $name) = @_;
20 4     24   31 return sub { delete $_[0]->$name()->{$_[1]} };
21             },
22             reset => sub {
23             my ($attr, $name) = @_;
24 4     6   27 return sub { $_[0]->$name()->{$_[1]} = 0 };
25             },
26             };
27             },
28             );
29              
30             subtype 'Bag', as 'HashRef[Int]';
31              
32 1     1 1 3 sub helper_type { 'Bag' }
33 3     3 1 675 sub helper_default { sub { +{} } }
  6     6   47  
34              
35 5     5   35 no Mouse;
  5         15  
  5         40  
36 5     5   725 no Mouse::Util::TypeConstraints;
  5         9  
  5         35  
37             __PACKAGE__->meta->make_immutable(inline_constructor => 0);
38             __END__