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