line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hades::Realm::Moo; |
2
|
8
|
|
|
8
|
|
2535247
|
use strict; |
|
8
|
|
|
|
|
72
|
|
|
8
|
|
|
|
|
203
|
|
3
|
8
|
|
|
8
|
|
38
|
use warnings; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
246
|
|
4
|
8
|
|
|
8
|
|
35
|
use base qw/Hades::Realm::OO/; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
4020
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.06; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
11
|
100
|
|
11
|
1
|
9540
|
my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ ); |
|
10
|
|
|
|
|
55
|
|
9
|
11
|
|
|
|
|
86
|
my $self = $cls->SUPER::new(%args); |
10
|
11
|
|
|
|
|
669
|
my %accessors = (); |
11
|
11
|
|
|
|
|
26
|
for my $accessor ( keys %accessors ) { |
12
|
|
|
|
|
|
|
my $param |
13
|
|
|
|
|
|
|
= defined $args{$accessor} |
14
|
|
|
|
|
|
|
? $args{$accessor} |
15
|
0
|
0
|
|
|
|
0
|
: $accessors{$accessor}->{default}; |
16
|
|
|
|
|
|
|
my $value |
17
|
|
|
|
|
|
|
= $self->$accessor( $accessors{$accessor}->{builder} |
18
|
0
|
0
|
|
|
|
0
|
? $accessors{$accessor}->{builder}->( $self, $param ) |
19
|
|
|
|
|
|
|
: $param ); |
20
|
0
|
0
|
0
|
|
|
0
|
unless ( !$accessors{$accessor}->{required} || defined $value ) { |
21
|
0
|
|
|
|
|
0
|
die "$accessor accessor is required"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
11
|
|
|
|
|
44
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub build_as_role { |
28
|
1
|
|
|
1
|
1
|
36856
|
my ( $orig, $self, @params ) = ( 'SUPER::build_as_role', @_ ); |
29
|
1
|
|
|
|
|
6
|
my @res = $self->$orig(@params); |
30
|
1
|
|
|
|
|
15
|
$res[0]->use(q|Moo::Role|); |
31
|
1
|
|
|
|
|
13
|
$res[0]->use(q|MooX::Private::Attribute|); |
32
|
|
|
|
|
|
|
$res[0]->use( |
33
|
|
|
|
|
|
|
sprintf q|Types::Standard qw/%s/|, |
34
|
1
|
|
|
|
|
7
|
join( ' ', keys %{ $self->meta->{ $self->current_class }->{types} } ) |
|
1
|
|
|
|
|
4
|
|
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
|
|
20
|
return wantarray ? @res : $res[0]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub build_as_class { |
41
|
9
|
|
|
9
|
1
|
127759
|
my ( $orig, $self, @params ) = ( 'SUPER::build_as_class', @_ ); |
42
|
9
|
|
|
|
|
50
|
my @res = $self->$orig(@params); |
43
|
9
|
|
|
|
|
136
|
$res[0]->use(q|Moo|); |
44
|
9
|
|
|
|
|
97
|
$res[0]->use(q|MooX::Private::Attribute|); |
45
|
|
|
|
|
|
|
$res[0]->use( |
46
|
|
|
|
|
|
|
sprintf q|Types::Standard qw/%s/|, |
47
|
9
|
|
|
|
|
63
|
join( ' ', keys %{ $self->meta->{ $self->current_class }->{types} } ) |
|
9
|
|
|
|
|
26
|
|
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
9
|
50
|
|
|
|
190
|
return wantarray ? @res : $res[0]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub build_has { |
54
|
38
|
|
|
38
|
1
|
3431112
|
my ( $self, $meta ) = @_; |
55
|
38
|
100
|
100
|
|
|
138
|
if ( ( ref($meta) || "" ) ne "HASH" ) { |
56
|
2
|
50
|
|
|
|
5
|
$meta = defined $meta ? $meta : 'undef'; |
57
|
2
|
|
|
|
|
18
|
die |
58
|
|
|
|
|
|
|
qq{HashRef: invalid value $meta for variable \$meta in method build_has}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
36
|
|
50
|
|
|
154
|
$meta->{is} ||= '"rw"'; |
62
|
|
|
|
|
|
|
my $attributes = join ', ', |
63
|
36
|
100
|
|
|
|
59
|
map { ( $meta->{$_} ? ( sprintf "%s => %s", $_, $meta->{$_} ) : () ) } |
|
360
|
|
|
|
|
661
|
|
64
|
|
|
|
|
|
|
qw/is required clearer predicate isa private default coerce trigger builder/; |
65
|
36
|
|
|
|
|
69
|
my $name = $meta->{has}; |
66
|
36
|
|
|
|
|
84
|
my $code = qq{ |
67
|
|
|
|
|
|
|
has $name => ( $attributes );}; |
68
|
36
|
|
|
|
|
81
|
return $code; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Hades::Realm::Moo - Hades realm for Moo |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Version 0.01 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Quick summary of what the module does: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Hades->run({ |
91
|
|
|
|
|
|
|
eval => q| |
92
|
|
|
|
|
|
|
Kosmos { |
93
|
|
|
|
|
|
|
[curae penthos] :t(Int) :d(2) :p :pr :c :r |
94
|
|
|
|
|
|
|
geras $nosoi :t(Int) :d(5) { |
95
|
|
|
|
|
|
|
if (£penthos == $nosoi) { |
96
|
|
|
|
|
|
|
return £curae; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|, |
101
|
|
|
|
|
|
|
realm => 'Moo', |
102
|
|
|
|
|
|
|
}); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
... generates ... |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
package Kosmos; |
107
|
|
|
|
|
|
|
use strict; |
108
|
|
|
|
|
|
|
use warnings; |
109
|
|
|
|
|
|
|
use Moo; |
110
|
|
|
|
|
|
|
use MooX::Private::Attribute; |
111
|
|
|
|
|
|
|
use Types::Standard qw/Int/; |
112
|
|
|
|
|
|
|
our $VERSION = 0.01; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
has curae => ( |
115
|
|
|
|
|
|
|
is => "rw", |
116
|
|
|
|
|
|
|
required => 1, |
117
|
|
|
|
|
|
|
clearer => 1, |
118
|
|
|
|
|
|
|
predicate => 1, |
119
|
|
|
|
|
|
|
isa => Int, |
120
|
|
|
|
|
|
|
private => 1, |
121
|
|
|
|
|
|
|
default => sub {2} |
122
|
|
|
|
|
|
|
); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
has penthos => ( |
125
|
|
|
|
|
|
|
is => "rw", |
126
|
|
|
|
|
|
|
required => 1, |
127
|
|
|
|
|
|
|
clearer => 1, |
128
|
|
|
|
|
|
|
predicate => 1, |
129
|
|
|
|
|
|
|
isa => Int, |
130
|
|
|
|
|
|
|
private => 1, |
131
|
|
|
|
|
|
|
default => sub {2} |
132
|
|
|
|
|
|
|
); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub geras { |
135
|
|
|
|
|
|
|
my ( $self, $nosoi ) = @_; |
136
|
|
|
|
|
|
|
$nosoi = defined $nosoi ? $nosoi : 5; |
137
|
|
|
|
|
|
|
if ( !defined($nosoi) || ref $nosoi || $nosoi !~ m/^[-+\d]\d*$/ ) { |
138
|
|
|
|
|
|
|
$nosoi = defined $nosoi ? $nosoi : 'undef'; |
139
|
|
|
|
|
|
|
die qq{Int: invalid value $nosoi for variable \$nosoi in method geras}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
if ( £penthos == $nosoi ) { return £curae; } |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
__END__ |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 new |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Instantiate a new Hades::Realm::Moo object. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Hades::Realm::Moo->new |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 build_as_role |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
call build_as_role method. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 build_as_class |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
call build_as_class method. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 build_has |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
call build_has method. Expects param $meta to be a HashRef. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$obj->build_has($meta) |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 AUTHOR |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
LNATION, C<< <email at lnation.org> >> |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 BUGS |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-hades::realm::moo at rt.cpan.org>, or through |
177
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Realm-Moo>. I will be notified, and then you'll |
178
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SUPPORT |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
perldoc Hades::Realm::Moo |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
You can also look for information at: |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=over 4 |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Realm-Moo> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Hades-Realm-Moo> |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * CPAN Ratings |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
L<https://cpanratings.perl.org/d/Hades-Realm-Moo> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * Search CPAN |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
L<https://metacpan.org/release/Hades-Realm-Moo> |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=back |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by LNATION. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This is free software, licensed under: |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|