line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hades::Realm::Moose; |
2
|
8
|
|
|
8
|
|
2417557
|
use strict; |
|
8
|
|
|
|
|
69
|
|
|
8
|
|
|
|
|
197
|
|
3
|
8
|
|
|
8
|
|
38
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
220
|
|
4
|
8
|
|
|
8
|
|
36
|
use base qw/Hades::Realm::OO/; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
3991
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.06; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
14
|
100
|
|
14
|
1
|
19814
|
my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ ); |
|
13
|
|
|
|
|
68
|
|
9
|
14
|
|
|
|
|
105
|
my $self = $cls->SUPER::new(%args); |
10
|
14
|
|
|
|
|
941
|
my %accessors = (); |
11
|
14
|
|
|
|
|
39
|
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
|
14
|
|
|
|
|
68
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub build_as_role { |
28
|
1
|
|
|
1
|
1
|
33170
|
my ( $orig, $self, @params ) = ( 'SUPER::build_as_role', @_ ); |
29
|
1
|
|
|
|
|
9
|
my @res = $self->$orig(@params); |
30
|
1
|
|
|
|
|
19
|
$res[0]->use(q|Moose::Role|); |
31
|
|
|
|
|
|
|
$res[0]->use( |
32
|
|
|
|
|
|
|
sprintf q|Types::Standard qw/%s/|, |
33
|
1
|
|
|
|
|
11
|
join( ' ', keys %{ $self->meta->{ $self->current_class }->{types} } ) |
|
1
|
|
|
|
|
4
|
|
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
1
|
50
|
|
|
|
25
|
return wantarray ? @res : $res[0]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub build_as_class { |
40
|
9
|
|
|
9
|
1
|
59176
|
my ( $orig, $self, @params ) = ( 'SUPER::build_as_class', @_ ); |
41
|
9
|
|
|
|
|
55
|
my @res = $self->$orig(@params); |
42
|
9
|
|
|
|
|
133
|
$res[0]->use(q|Moose|); |
43
|
9
|
|
|
|
|
108
|
$res[0]->use(q|MooseX::Privacy|); |
44
|
|
|
|
|
|
|
$res[0]->use( |
45
|
|
|
|
|
|
|
sprintf q|Types::Standard qw/%s/|, |
46
|
9
|
|
|
|
|
66
|
join( ' ', keys %{ $self->meta->{ $self->current_class }->{types} } ) |
|
9
|
|
|
|
|
26
|
|
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
9
|
50
|
|
|
|
195
|
return wantarray ? @res : $res[0]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub build_has { |
53
|
38
|
|
|
38
|
1
|
3576529
|
my ( $self, $meta ) = @_; |
54
|
38
|
100
|
100
|
|
|
127
|
if ( ( ref($meta) || "" ) ne "HASH" ) { |
55
|
2
|
50
|
|
|
|
7
|
$meta = defined $meta ? $meta : 'undef'; |
56
|
2
|
|
|
|
|
23
|
die |
57
|
|
|
|
|
|
|
qq{HashRef: invalid value $meta for variable \$meta in method build_has}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
36
|
|
50
|
|
|
211
|
$meta->{is} ||= '"rw"'; |
61
|
|
|
|
|
|
|
my $attributes = join ', ', |
62
|
36
|
100
|
|
|
|
58
|
map { ( $meta->{$_} ? ( sprintf "%s => %s", $_, $meta->{$_} ) : () ) } |
|
288
|
|
|
|
|
595
|
|
63
|
|
|
|
|
|
|
qw/is required clearer predicate isa default trigger builder/; |
64
|
36
|
100
|
|
|
|
92
|
$attributes .= ', traits => [qw/Private/]' if ( $meta->{private} ); |
65
|
36
|
|
|
|
|
58
|
my $name = $meta->{has}; |
66
|
36
|
|
|
|
|
84
|
my $code = qq{ |
67
|
|
|
|
|
|
|
has $name => ( $attributes );}; |
68
|
36
|
|
|
|
|
82
|
return $code; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub build_accessor_predicate { |
73
|
10
|
|
|
10
|
1
|
2875
|
my ( $self, $name, $content ) = @_; |
74
|
10
|
100
|
66
|
|
|
54
|
if ( !defined($name) || ref $name ) { |
75
|
2
|
50
|
|
|
|
6
|
$name = defined $name ? $name : 'undef'; |
76
|
2
|
|
|
|
|
22
|
die |
77
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_accessor_predicate}; |
78
|
|
|
|
|
|
|
} |
79
|
8
|
100
|
66
|
|
|
39
|
if ( !defined($content) || ref $content ) { |
80
|
2
|
50
|
|
|
|
6
|
$content = defined $content ? $content : 'undef'; |
81
|
2
|
|
|
|
|
30
|
die |
82
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method build_accessor_predicate}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
6
|
|
|
|
|
22
|
return qq|"has_$name"|; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub build_accessor_clearer { |
90
|
14
|
|
|
14
|
1
|
65185
|
my ( $self, $name, $content ) = @_; |
91
|
14
|
100
|
66
|
|
|
100
|
if ( !defined($name) || ref $name ) { |
92
|
2
|
50
|
|
|
|
6
|
$name = defined $name ? $name : 'undef'; |
93
|
2
|
|
|
|
|
22
|
die |
94
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_accessor_clearer}; |
95
|
|
|
|
|
|
|
} |
96
|
12
|
100
|
66
|
|
|
50
|
if ( !defined($content) || ref $content ) { |
97
|
2
|
50
|
|
|
|
6
|
$content = defined $content ? $content : 'undef'; |
98
|
2
|
|
|
|
|
18
|
die |
99
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method build_accessor_clearer}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
10
|
|
|
|
|
38
|
return qq|"clear_$name"|; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub build_accessor_builder { |
107
|
5
|
|
|
5
|
1
|
5874
|
my ( $self, $name, $content ) = @_; |
108
|
5
|
100
|
66
|
|
|
29
|
if ( !defined($name) || ref $name ) { |
109
|
2
|
50
|
|
|
|
6
|
$name = defined $name ? $name : 'undef'; |
110
|
2
|
|
|
|
|
22
|
die |
111
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_accessor_builder}; |
112
|
|
|
|
|
|
|
} |
113
|
3
|
100
|
66
|
|
|
16
|
if ( !defined($content) || ref $content ) { |
114
|
2
|
50
|
|
|
|
8
|
$content = defined $content ? $content : 'undef'; |
115
|
2
|
|
|
|
|
17
|
die |
116
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method build_accessor_builder}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
1
|
50
|
|
|
|
19
|
return $content =~ m/^\w\w+$/ ? $content : qq|"_build_$name"|; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 NAME |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Hades::Realm::Moose - Hades realm for Moose |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 VERSION |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Version 0.01 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SYNOPSIS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Quick summary of what the module does: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Hades->run({ |
142
|
|
|
|
|
|
|
eval => q| |
143
|
|
|
|
|
|
|
Kosmos { |
144
|
|
|
|
|
|
|
[curae penthos] :t(Int) :d(2) :p :pr :c :r |
145
|
|
|
|
|
|
|
geras $nosoi :t(Int) :d(5) { |
146
|
|
|
|
|
|
|
if (£penthos == $nosoi) { |
147
|
|
|
|
|
|
|
return £curae; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|, |
152
|
|
|
|
|
|
|
realm => 'Moose', |
153
|
|
|
|
|
|
|
}); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
... generates ... |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
package Kosmos; |
158
|
|
|
|
|
|
|
use strict; |
159
|
|
|
|
|
|
|
use warnings; |
160
|
|
|
|
|
|
|
use Moose; |
161
|
|
|
|
|
|
|
use MooseX::Privacy; |
162
|
|
|
|
|
|
|
use Types::Standard qw/Int/; |
163
|
|
|
|
|
|
|
our $VERSION = 0.01; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
has curae => ( |
166
|
|
|
|
|
|
|
is => "rw", |
167
|
|
|
|
|
|
|
required => 1, |
168
|
|
|
|
|
|
|
clearer => "clear_curae", |
169
|
|
|
|
|
|
|
predicate => "has_curae", |
170
|
|
|
|
|
|
|
isa => Int, |
171
|
|
|
|
|
|
|
default => sub {2}, |
172
|
|
|
|
|
|
|
traits => [qw/Private/] |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
has penthos => ( |
176
|
|
|
|
|
|
|
is => "rw", |
177
|
|
|
|
|
|
|
required => 1, |
178
|
|
|
|
|
|
|
clearer => "clear_penthos", |
179
|
|
|
|
|
|
|
predicate => "has_penthos", |
180
|
|
|
|
|
|
|
isa => Int, |
181
|
|
|
|
|
|
|
default => sub {2}, |
182
|
|
|
|
|
|
|
traits => [qw/Private/] |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub geras { |
186
|
|
|
|
|
|
|
my ( $self, $nosoi ) = @_; |
187
|
|
|
|
|
|
|
$nosoi = defined $nosoi ? $nosoi : 5; |
188
|
|
|
|
|
|
|
if ( !defined($nosoi) || ref $nosoi || $nosoi !~ m/^[-+\d]\d*$/ ) { |
189
|
|
|
|
|
|
|
$nosoi = defined $nosoi ? $nosoi : 'undef'; |
190
|
|
|
|
|
|
|
die qq{Int: invalid value $nosoi for variable \$nosoi in method geras}; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
if ( £penthos == $nosoi ) { return £curae; } |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
1; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
__END__ |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
NOTE: coerce attributes currently do not work with Moose |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 new |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Instantiate a new Hades::Realm::Moose object. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Hades::Realm::Moose->new |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 build_as_role |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
call build_as_role method. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 build_as_class |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
call build_as_class method. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 build_has |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
call build_has method. Expects param $meta to be a HashRef. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
$obj->build_has($meta) |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 build_accessor_predicate |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
call build_accessor_predicate method. Expects param $name to be a Str, param $content to be a Str. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
$obj->build_accessor_predicate($name, $content) |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 build_accessor_clearer |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
call build_accessor_clearer method. Expects param $name to be a Str, param $content to be a Str. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
$obj->build_accessor_clearer($name, $content) |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 build_accessor_builder |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
call build_accessor_builder method. Expects param $name to be a Str, param $content to be a Str. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
$obj->build_accessor_builder($name, $content) |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 AUTHOR |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
LNATION, C<< <email at lnation.org> >> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 BUGS |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-hades::realm::moose at rt.cpan.org>, or through |
248
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Realm-Moose>. I will be notified, and then you'll |
249
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 SUPPORT |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
perldoc Hades::Realm::Moose |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
You can also look for information at: |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=over 4 |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Realm-Moose> |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Hades-Realm-Moose> |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item * CPAN Ratings |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
L<https://cpanratings.perl.org/d/Hades-Realm-Moose> |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=item * Search CPAN |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
L<https://metacpan.org/release/Hades-Realm-Moose> |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=back |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by LNATION. |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
This is free software, licensed under: |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=cut |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
|