line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
# $Source$ |
3
|
|
|
|
|
|
|
# $Author$ |
4
|
|
|
|
|
|
|
# $HeadURL$ |
5
|
|
|
|
|
|
|
# $Revision$ |
6
|
|
|
|
|
|
|
# $Date$ |
7
|
|
|
|
|
|
|
package Class::Dot::Meta::Role; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
630
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
11
|
1
|
|
|
1
|
|
5
|
use version; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
12
|
1
|
|
|
1
|
|
92
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
104
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = qv('2.0.0_15'); |
15
|
|
|
|
|
|
|
our $AUTHORITY = 'CPAN:asksh'; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
5
|
use Carp qw(confess); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use Class::Dot::Registry; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
276
|
|
20
|
|
|
|
|
|
|
my $REGISTRY = Class::Dot::Registry->new(); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub mixin_with { |
23
|
2
|
|
|
2
|
0
|
5
|
my ($self, $the_class, $with) = @_; |
24
|
2
|
50
|
|
|
|
21
|
my $class = ref $the_class ? $the_class |
25
|
|
|
|
|
|
|
: $the_class->new(); |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
6
|
return _apply_attributes($with, $class); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _apply_attributes { |
32
|
2
|
|
|
2
|
|
5
|
my ($self, $other) = @_; |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
11
|
my $self_metaclass = $self->__metaclass__(); |
35
|
2
|
|
|
|
|
10
|
my $other_metaclass = $other->__metaclass__(); |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
3
|
my %self_meta = %{ $self->__meta__() }; |
|
2
|
|
|
|
|
8
|
|
38
|
2
|
|
|
|
|
9
|
while (my ($attr_name, $attr_isa) = each %self_meta) { |
39
|
|
|
|
|
|
|
|
40
|
4
|
100
|
66
|
|
|
14
|
if ($other->__hasattr__($attr_name) && |
41
|
|
|
|
|
|
|
($other->__meta__($attr_name)->__isa__ != $attr_isa)) |
42
|
|
|
|
|
|
|
{ |
43
|
2
|
50
|
|
|
|
12
|
if ($other->isa('Class::Meta::Role')) { |
44
|
0
|
|
|
|
|
0
|
confess "Fatal error: Role [" . ref $self . "] has en" . #- |
45
|
|
|
|
|
|
|
"countered an attribute conflict during composition." |
46
|
|
|
|
|
|
|
; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
2
|
|
|
|
|
8
|
next; # pass |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else { |
53
|
2
|
|
|
|
|
7
|
$other_metaclass->property->define_property( |
54
|
|
|
|
|
|
|
($attr_name, $attr_isa) => ref $other |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
11
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |