File Coverage

blib/lib/Method/Generate/Accessor/Role/InsideOut.pm
Criterion Covered Total %
statement 18 28 64.2
branch n/a
condition n/a
subroutine 6 9 66.6
pod 0 1 0.0
total 24 38 63.1


line stmt bran cond sub pod time code
1             package Method::Generate::Accessor::Role::InsideOut;
2 2     2   20595 use Moo::Role;
  2         201777  
  2         18  
3              
4 2     2   2638 use Hash::Util::FieldHash::Compat qw(fieldhash);
  2         78461  
  2         17  
5 2     2   125 use B qw(perlstring);
  2         5  
  2         889  
6              
7             fieldhash our %FIELDS;
8              
9             around generate_method => sub {
10             my $orig = shift;
11             my $self = shift;
12             # would like a better way to disable XS
13             local $Method::Generate::Accessor::CAN_HAZ_XS = 0;
14             $self->$orig(@_);
15             };
16              
17             sub _generate_simple_has {
18 0     0   0 my ($self, $me, $name) = @_;
19 0         0 my $name_str = perlstring $name;
20 0         0 $self->{captures}{'$FIELDS'} = \\%FIELDS;
21 0         0 "exists \$FIELDS->{${me}}->{${$name_str}}";
  0         0  
22             }
23              
24             sub _generate_simple_clear {
25 0     0   0 my ($self, $me, $name) = @_;
26 0         0 my $name_str = perlstring $name;
27 0         0 $self->{captures}{'$FIELDS'} = \\%FIELDS;
28 0         0 " delete \$FIELDS->{${me}}->{${name_str}}";
29             }
30              
31             sub _generate_simple_get {
32 2     2   165 my ($self, $me, $name) = @_;
33 2         11 my $name_str = perlstring $name;
34 2         8 $self->{captures}{'$FIELDS'} = \\%FIELDS;
35 2         12 "\$FIELDS->{${me}}->{${name_str}}";
36             }
37              
38             sub _generate_core_set {
39 3     3   622 my ($self, $me, $name, $spec, $value) = @_;
40 3         11 my $name_str = perlstring $name;
41 3         9 $self->{captures}{'$FIELDS'} = \\%FIELDS;
42 3         15 "\$FIELDS->{${me}}->{${name_str}} = ${value}";
43             }
44              
45             sub _generate_xs {
46 0     0   0 die "Can't generate XS accessors for inside out objects";
47             }
48              
49 1     1 0 255 sub default_construction_string { '\(my $s)' }
50              
51             1;