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