2 package Class::MOP::Method;
8 use Scalar::Util 'reftype', 'blessed';
10 our $VERSION = '0.06';
11 our $AUTHORITY = 'cpan:STEVAN';
13 use base 'Class::MOP::Object';
16 # if poked in the right way,
17 # they should act like CODE refs.
18 use overload '&{}' => sub { $_[0]->body }, fallback => 1;
25 ('CODE' eq (reftype($code) || ''))
26 || confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
29 } => blessed($class) || $class;
34 sub body { (shift)->{'&!body'} }
36 # TODO - add associated_class
41 # this may not be the same name
42 # as the class you got it from
43 # This gets the package stash name
44 # associated with the actual CODE-ref
46 my $code = (shift)->body;
47 (Class::MOP::get_code_info($code))[0];
51 # this may not be the same name
52 # as the method name it is stored
53 # with. This gets the name associated
54 # with the actual CODE-ref
56 my $code = (shift)->body;
57 (Class::MOP::get_code_info($code))[1];
60 sub fully_qualified_name {
62 $code->package_name . '::' . $code->name;
73 Class::MOP::Method - Method Meta Object
77 The Method Protocol is very small, since methods in Perl 5 are just
78 subroutines within the particular package. We provide a very basic
79 introspection interface.
89 This will return a B<Class::MOP::Class> instance which is related
100 This is the basic constructor, it returns a B<Class::MOP::Method>
101 instance which wraps the given C<$code> reference.
111 This returns the actual CODE reference of the particular instance.
115 This returns the name of the CODE reference.
117 =item B<package_name>
119 This returns the package name that the CODE reference is attached to.
121 =item B<fully_qualified_name>
123 This returns the fully qualified name of the CODE reference.
129 Stevan Little E<lt>stevan@iinteractive.comE<gt>
131 =head1 COPYRIGHT AND LICENSE
133 Copyright 2006-2008 by Infinity Interactive, Inc.
135 L<http://www.iinteractive.com>
137 This library is free software; you can redistribute it and/or modify
138 it under the same terms as Perl itself.