Attributes/Trait/Attribute/Native/Trait.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 31 / 31 CC 2 SCAR 2.5
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Attributes/Trait/Role/Application/ToClass.pm ↑ Summary Attributes/Util.pm »
1 #
2 # This file is part of MooseX-TrackDirty-Attributes
3 #
4 # This software is Copyright (c) 2011 by Chris Weyl.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package MooseX::TrackDirty::Attributes::Trait::Attribute::Native::Trait;
11 9 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 $MooseX::TrackDirty::Attributes::Trait::Attribute::Native::Trait::AUTHORITY = 'cpan:RSRCHBOY';
13 }
14 9 $MooseX::TrackDirty::Attributes::Trait::Attribute::Native::Trait::VERSION = '2.003';
15 # ABSTRACT: Compatibility trait between the track-dirty and native traits
16  
17 9 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 9 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 9 ▶use MooseX::TrackDirty::Attributes::Util ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 9 ▶use Class::Load 'load_class';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # debugging...
24 #use Smart::Comments;
25  
26 # We wrap _native_accessor_class_for() to catch the generated accessor
27 # classes; if they use the native Writer trait, then we apply our shim trait
28 # to ensure that dirtyness is properly tracked.
29  
30 9 requires '_native_accessor_class_for';
31  
32 32 ▶around _native_accessor_class_for => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
33 32 my ($orig, $self) = (shift, shift);
34 32 my ($suffix) = @_;
35  
36 32 my $class = $self->$orig(@_);
37  
38 32 ▶ return $class unless $class
Branch: 1 branch
BranchTrueFalseTotal
unless $class->meta->does_role("Moose::Meta::Method::Accessor::Native::Writer") 16 16 32
39 ->meta
40 ->does_role('Moose::Meta::Method::Accessor::Native::Writer')
41 ;
42  
43 16 my $new_class = Moose::Meta::Class->create_anon_class(
44 superclasses => [ $class ],
45 roles => [ AccessorNativeTrait ],
46 cache => 1,
47 );
48  
49 16 return $new_class->name;
50 9 };
51  
52 9 !!42;
53  
54 __END__
« Attributes/Trait/Role/Application/ToClass.pm ↑ Summary Attributes/Util.pm »