File Coverage

blib/lib/MooseX/TrackDirty/Attributes/Trait/Role/Application/ToRole.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::Role::Application::ToRole;
11             {
12             $MooseX::TrackDirty::Attributes::Trait::Role::Application::ToRole::VERSION = '1.900'; # TRIAL
13             }
14              
15             # ABSTRACT: Application to role helper trait
16              
17 11     11   35273 use Moose::Role;
  11         18  
  11         53  
18 11     11   35193 use namespace::autoclean;
  11         17  
  11         70  
19 11     11   510 use Moose::Util::MetaRole;
  11         15  
  11         239  
20 11     11   37 use MooseX::TrackDirty::Attributes::Util ':all';
  11         12  
  11         61  
21              
22             # debug...
23             #use Smart::Comments;
24              
25              
26             around apply => sub {
27             my ($next, $self, $role1, $role2) = @_;
28              
29             ### role1 (source): $role1->name
30             ### role2 (target): $role2->name
31              
32             $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             unless $role2->does_role('Moose::Meta::Attribute::Native::Trait');
48              
49             ### applying TrackDirtyNativeTrait to: $role2->name
50             TrackDirtyNativeTrait->meta->apply($role2);
51             return;
52             };
53              
54             !!42;
55              
56             __END__
57             =pod
58              
59             =encoding utf-8
60              
61             =head1 NAME
62              
63             MooseX::TrackDirty::Attributes::Trait::Role::Application::ToRole - Application to role helper trait
64              
65             =head1 VERSION
66              
67             This document describes 1.900 of MooseX::TrackDirty::Attributes::Trait::Role::Application::ToRole - released February 15, 2012 as part of MooseX-TrackDirty-Attributes.
68              
69             =head1 METHODS
70              
71             =head2 apply
72              
73             =head1 SEE ALSO
74              
75             Please see those modules/websites for more information related to this module.
76              
77             =over 4
78              
79             =item *
80              
81             L<MooseX::TrackDirty::Attributes|MooseX::TrackDirty::Attributes>
82              
83             =back
84              
85             =head1 SOURCE
86              
87             The development version is on github at L<http://github.com/RsrchBoy/moosex-trackdirty-attributes>
88             and may be cloned from L<git://github.com/RsrchBoy/moosex-trackdirty-attributes.git>
89              
90             =head1 BUGS
91              
92             Please report any bugs or feature requests on the bugtracker website
93             https://github.com/RsrchBoy/moosex-trackdirty-attributes/issues
94              
95             When submitting a bug or request, please include a test-file or a
96             patch to an existing test-file that illustrates the bug or desired
97             feature.
98              
99             =head1 AUTHOR
100              
101             Chris Weyl <cweyl@alumni.drew.edu>
102              
103             =head1 COPYRIGHT AND LICENSE
104              
105             This software is Copyright (c) 2011 by Chris Weyl.
106              
107             This is free software, licensed under:
108              
109             The GNU Lesser General Public License, Version 2.1, February 1999
110              
111             =cut
112