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::Accessor::Chained; |
8
|
16
|
|
|
16
|
|
12258
|
use base 'Class::Dot::Meta::Accessor::Base'; |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
5695
|
|
9
|
|
|
|
|
|
|
|
10
|
16
|
|
|
16
|
|
97
|
use strict; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
469
|
|
11
|
16
|
|
|
16
|
|
82
|
use warnings; |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
398
|
|
12
|
16
|
|
|
16
|
|
85
|
use version; |
|
16
|
|
|
|
|
30
|
|
|
16
|
|
|
|
|
107
|
|
13
|
16
|
|
|
16
|
|
1213
|
use 5.00600; |
|
16
|
|
|
|
|
83
|
|
|
16
|
|
|
|
|
1682
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = qv('2.0.0_15'); |
16
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:ASKSH'; |
17
|
|
|
|
|
|
|
|
18
|
16
|
|
|
16
|
|
173
|
use Carp qw(croak confess); |
|
16
|
|
|
|
|
49
|
|
|
16
|
|
|
|
|
3341
|
|
19
|
|
|
|
|
|
|
|
20
|
16
|
|
|
16
|
|
116
|
use Class::Dot::Devel::Sub::Name qw(subname); |
|
16
|
|
|
|
|
173
|
|
|
16
|
|
|
|
|
179
|
|
21
|
|
|
|
|
|
|
|
22
|
16
|
|
|
16
|
|
86
|
use Class::Dot::Meta::Type qw(_NEWSCHOOL_TYPE _OLDSCHOOL_TYPE); |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
105
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub register_plugin { |
25
|
|
|
|
|
|
|
return { |
26
|
16
|
|
|
16
|
0
|
400
|
name => 'Chained', |
27
|
|
|
|
|
|
|
class => __PACKAGE__, |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub create_get_accessor { |
32
|
6
|
|
|
6
|
0
|
14
|
my ($self, @args) = @_; |
33
|
6
|
|
|
|
|
13
|
return $self->create_mutator(@args); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub create_set_accessor { |
37
|
6
|
|
|
6
|
0
|
7
|
my ($self, $caller_class, $property, $isa, $options) = @_; |
38
|
6
|
|
|
|
|
14
|
my $property_key = $property; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return subname "${caller_class}::set_$property" => sub { |
41
|
4
|
|
|
4
|
|
6
|
my ($self, $value) = @_; |
|
|
|
|
25
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
18
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
4
|
50
|
|
|
|
10
|
if ($options->{'-optimized'}) { |
44
|
0
|
|
|
|
|
0
|
$self->{$property_key} = $value; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
4
|
|
|
|
|
13
|
$self->__setattr__($property, $value); |
48
|
|
|
|
|
|
|
} |
49
|
4
|
|
|
|
|
15
|
return $self; # <-- this is the chained part. |
50
|
|
|
|
|
|
|
} |
51
|
6
|
|
|
|
|
59
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub create_mutator { |
54
|
9
|
|
|
9
|
0
|
20
|
my ($self, $caller_class, $property, $isa, $options, $priv) = @_; |
55
|
9
|
|
|
|
|
13
|
my $property_key = $property; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return subname "${caller_class}::$property" => sub { |
58
|
21
|
|
|
21
|
|
2485
|
my ($self, $value) = @_; |
59
|
|
|
|
|
|
|
|
60
|
21
|
100
|
|
|
|
60
|
if (defined $value) { |
61
|
7
|
100
|
|
|
|
48
|
confess "Can't set value with $property(). It's read only!" |
62
|
|
|
|
|
|
|
if not $priv->{has_setter}; |
63
|
6
|
100
|
|
|
|
14
|
if ($options->{'-optimized'}) { |
64
|
2
|
|
|
|
|
4
|
$self->{$property_key} = $value; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
4
|
|
|
|
|
11
|
$self->__setattr__($property, $value); |
68
|
|
|
|
|
|
|
} |
69
|
6
|
|
|
|
|
24
|
return $self; # <-- this is the chained part. |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
14
|
50
|
|
|
|
42
|
if (not $priv->{has_getter}) { |
73
|
0
|
|
|
|
|
0
|
confess "Can only set value with $property(), it's write only!"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
14
|
100
|
|
|
|
43
|
if (!exists $self->{$property_key}) { |
77
|
|
|
|
|
|
|
|
78
|
4
|
50
|
|
|
|
17
|
if (_NEWSCHOOL_TYPE($isa)) { |
|
|
0
|
|
|
|
|
|
79
|
4
|
|
|
|
|
17
|
$self->{$property_key} = $isa->default_value($self); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
elsif (_OLDSCHOOL_TYPE($isa)) { |
82
|
0
|
|
|
|
|
0
|
$self->{$property_key} = $isa->($self); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
0
|
|
|
|
|
0
|
$self->{$property_key} = $isa; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
14
|
100
|
|
|
|
89
|
return $options->{'-optimized'} ? $self->{$property_key} |
90
|
|
|
|
|
|
|
: $self->__getattr__($property); |
91
|
|
|
|
|
|
|
} |
92
|
9
|
|
|
|
|
119
|
} |
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |