| 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::Role::Application::ToRole; | ||||||||||
| 11 | 9 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 9 | $MooseX::TrackDirty::Attributes::Trait::Role::Application::ToRole::AUTHORITY = 'cpan:RSRCHBOY'; | |||||||||
| 13 | } | ||||||||||
| 14 | 9 | $MooseX::TrackDirty::Attributes::Trait::Role::Application::ToRole::VERSION = '2.003'; | |||||||||
| 15 | # ABSTRACT: Application to role helper trait | ||||||||||
| 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 Moose::Util::MetaRole; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 9 | ▶ | use MooseX::TrackDirty::Attributes::Util ':all'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | # debug... | ||||||||||
| 23 | #use Smart::Comments; | ||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | around apply => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.4
| |||||||||||
| 27 | 1 | my ($next, $self, $role1, $role2) = @_; | |||||||||
| 28 | |||||||||||
| 29 | ### role1 (source): $role1->name | ||||||||||
| 30 | ### role2 (target): $role2->name | ||||||||||
| 31 | |||||||||||
| 32 | 1 | $self->$next( | |||||||||
| 33 | $role1, | ||||||||||
| 34 | Moose::Util::MetaRole::apply_metaroles( | ||||||||||
| 35 | for => $role2, | ||||||||||
| 36 | role_metaroles => { | ||||||||||
| 37 | role => [ trait_for 'Role' ], | ||||||||||
| 38 | application_to_class => [ ToClass ], | ||||||||||
| 39 | application_to_role => [ __PACKAGE__ ], | ||||||||||
| 40 | application_to_instance => [ ToInstance ], | ||||||||||
| 41 | }, | ||||||||||
| 42 | ), | ||||||||||
| 43 | ); | ||||||||||
| 44 | |||||||||||
| 45 | ### check to see if our target now does the native trait... | ||||||||||
| 46 | return | ||||||||||
| 47 | 1 | ▶ | unless $role2->does_role('Moose::Meta::Attribute::Native::Trait'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | |||||||||||
| 49 | ### applying TrackDirtyNativeTrait to: $role2->name | ||||||||||
| 50 | 0 | TrackDirtyNativeTrait->meta->apply($role2); | |||||||||
| 51 | 0 | return; | |||||||||
| 52 | 9 | }; | |||||||||
| 53 | |||||||||||
| 54 | 9 | !!42; | |||||||||
| 55 | |||||||||||
| 56 | __END__ | ||||||||||