File Coverage

blib/lib/MooseX/TrackDirty/Attributes/Trait/Attribute/Native/Trait.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
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             {
12             $MooseX::TrackDirty::Attributes::Trait::Attribute::Native::Trait::VERSION = '1.900'; # TRIAL
13             }
14              
15             # ABSTRACT: Compatibility trait between the track-dirty and native traits
16              
17 11     11   42 use Moose::Role;
  11         13  
  11         76  
18 11     11   36822 use namespace::autoclean;
  11         17  
  11         93  
19 11     11   692 use MooseX::TrackDirty::Attributes::Util ':all';
  11         15  
  11         272  
20              
21 11     11   5077 use Class::Load 'load_class';
  11         14  
  11         1978  
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             requires '_native_accessor_class_for';
31              
32             around _native_accessor_class_for => sub {
33             my ($orig, $self) = (shift, shift);
34             my ($suffix) = @_;
35              
36             my $class = $self->$orig(@_);
37              
38             return $class unless $class
39             ->meta
40             ->does_role('Moose::Meta::Method::Accessor::Native::Writer')
41             ;
42              
43             my $new_class = Moose::Meta::Class->create_anon_class(
44             superclasses => [ $class ],
45             roles => [ AccessorNativeTrait ],
46             cache => 1,
47             );
48              
49             return $new_class->name;
50             };
51              
52             !!42;
53              
54              
55             =pod
56              
57             =encoding utf-8
58              
59             =head1 NAME
60              
61             MooseX::TrackDirty::Attributes::Trait::Attribute::Native::Trait - Compatibility trait between the track-dirty and native traits
62              
63             =head1 VERSION
64              
65             This document describes 1.900 of MooseX::TrackDirty::Attributes::Trait::Attribute::Native::Trait - released February 15, 2012 as part of MooseX-TrackDirty-Attributes.
66              
67             =head1 SEE ALSO
68              
69             Please see those modules/websites for more information related to this module.
70              
71             =over 4
72              
73             =item *
74              
75             L<MooseX::TrackDirty::Attributes|MooseX::TrackDirty::Attributes>
76              
77             =back
78              
79             =head1 SOURCE
80              
81             The development version is on github at L<http://github.com/RsrchBoy/moosex-trackdirty-attributes>
82             and may be cloned from L<git://github.com/RsrchBoy/moosex-trackdirty-attributes.git>
83              
84             =head1 BUGS
85              
86             Please report any bugs or feature requests on the bugtracker website
87             https://github.com/RsrchBoy/moosex-trackdirty-attributes/issues
88              
89             When submitting a bug or request, please include a test-file or a
90             patch to an existing test-file that illustrates the bug or desired
91             feature.
92              
93             =head1 AUTHOR
94              
95             Chris Weyl <cweyl@alumni.drew.edu>
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             This software is Copyright (c) 2011 by Chris Weyl.
100              
101             This is free software, licensed under:
102              
103             The GNU Lesser General Public License, Version 2.1, February 1999
104              
105             =cut
106              
107              
108             __END__