| 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
| |||||||||||
| 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__ | ||||||||||