line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::DeclareX::Plugin::abstract; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
BEGIN { |
4
|
1
|
|
|
1
|
|
38790
|
$MooseX::DeclareX::Plugin::abstract::AUTHORITY = 'cpan:TOBYINK'; |
5
|
1
|
|
|
|
|
19
|
$MooseX::DeclareX::Plugin::abstract::VERSION = '0.004'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
518
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'MooseX::DeclareX::Plugin'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use MooseX::Declare (); |
12
|
|
|
|
|
|
|
use Moose::Util (); |
13
|
|
|
|
|
|
|
use MooseX::ABCD (); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub plugin_setup |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
my ($class, $kw) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if ($kw->isa('MooseX::DeclareX::Keyword::class')) |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
$kw->register_feature(abstract => \&_abstract); |
22
|
|
|
|
|
|
|
$kw->register_feature(concrete => sub { (1) }); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _abstract |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
my ($self, $ctx, $package) = @_; |
29
|
|
|
|
|
|
|
$ctx->add_scope_code_parts('use MooseX::ABCD'); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
MooseX::DeclareX::Plugin::abstract - shiny syntax for MooseX::ABCD |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
class Shape is abstract { |
43
|
|
|
|
|
|
|
requires 'draw'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
class Circle extends Shape { |
47
|
|
|
|
|
|
|
method draw { ... } |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
class Square extends Shape { |
51
|
|
|
|
|
|
|
# does not implement 'draw' |
52
|
|
|
|
|
|
|
} # dies |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $shape = Shape->new; # dies |
55
|
|
|
|
|
|
|
my $circle = Circle->new; # succeeds |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 DESCRIPTION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This distribution adds two new plugins to L<MooseX::DeclareX>. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item C<< is abstract >> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Declares that a class cannot be instantiated. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Also allows the standard Moose C<requires> function to work within |
68
|
|
|
|
|
|
|
classes (it normally only works within roles). |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
When a class requires a method, then subclasses are supposed to provide that |
71
|
|
|
|
|
|
|
method. If the subclass itself is also abstract, then it doesn't need to |
72
|
|
|
|
|
|
|
provide the required methods. (There's also a little cheat: classes which |
73
|
|
|
|
|
|
|
are mutable may extend abstract classes without implementing required methods. |
74
|
|
|
|
|
|
|
You should not do this though.) |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item C<< is concrete >> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
A counterpart to C<< is abstract >>. Currently, this is a no-op, but in |
79
|
|
|
|
|
|
|
future it might enable some checks related to abstract classes. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=back |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 BUGS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Please report any bugs to |
86
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=MooseX-DeclareX-Plugin-abstract>. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SEE ALSO |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
L<MooseX::DeclareX>, L<MooseX::ABCD>. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Toby Inkster. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
101
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
106
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
107
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
108
|
|
|
|
|
|
|
|