Commit | Line | Data |
8b978dd5 |
1 | |
2 | package Class::MOP::Method; |
3 | |
4 | use strict; |
5 | use warnings; |
6 | |
2eb717d5 |
7 | use Carp 'confess'; |
aa448b16 |
8 | use Scalar::Util 'reftype', 'blessed'; |
2eb717d5 |
9 | |
8b978dd5 |
10 | our $VERSION = '0.01'; |
2eb717d5 |
11 | |
727919c5 |
12 | sub meta { |
13 | require Class::MOP::Class; |
aa448b16 |
14 | Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); |
727919c5 |
15 | } |
2eb717d5 |
16 | |
17 | sub wrap { |
18 | my $class = shift; |
19 | my $code = shift; |
20 | |
21 | (reftype($code) && reftype($code) eq 'CODE') |
22 | || confess "You must supply a CODE reference to wrap"; |
23 | |
24 | bless $code => $class; |
25 | } |
8b978dd5 |
26 | |
27 | 1; |
28 | |
29 | __END__ |
30 | |
31 | =pod |
32 | |
33 | =head1 NAME |
34 | |
35 | Class::MOP::Method - Method Meta Object |
36 | |
37 | =head1 SYNOPSIS |
38 | |
fe122940 |
39 | # ... more to come later maybe |
40 | |
8b978dd5 |
41 | =head1 DESCRIPTION |
42 | |
552e3d24 |
43 | The Method Protocol is very small, since methods in Perl 5 are just |
44 | subroutines within the particular package. Basically all we do is to |
fe122940 |
45 | bless the subroutine. |
46 | |
47 | Currently this package is largely unused. Future plans are to provide |
48 | some very simple introspection methods for the methods themselves. |
49 | Suggestions for this are welcome. |
552e3d24 |
50 | |
2eb717d5 |
51 | =head1 METHODS |
52 | |
53 | =over 4 |
54 | |
55 | =item B<wrap (&code)> |
56 | |
fe122940 |
57 | This simply blesses the C<&code> reference passed to it. |
58 | |
2eb717d5 |
59 | =item B<meta> |
60 | |
fe122940 |
61 | This will return a B<Class::MOP::Class> instance which is related |
62 | to this class. |
63 | |
2eb717d5 |
64 | =back |
65 | |
8b978dd5 |
66 | =head1 AUTHOR |
67 | |
a2e85e6c |
68 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
8b978dd5 |
69 | |
70 | =head1 COPYRIGHT AND LICENSE |
71 | |
72 | Copyright 2006 by Infinity Interactive, Inc. |
73 | |
74 | L<http://www.iinteractive.com> |
75 | |
76 | This library is free software; you can redistribute it and/or modify |
77 | it under the same terms as Perl itself. |
78 | |
79 | =cut |