2 package Class::MOP::Method;
8 use Scalar::Util 'reftype', 'blessed';
11 our $VERSION = '0.05';
12 our $AUTHORITY = 'cpan:STEVAN';
14 use base 'Class::MOP::Object';
17 # if poked in the right way,
18 # they should act like CODE refs.
19 use overload '&{}' => sub { $_[0]->body }, fallback => 1;
24 require Class::MOP::Class;
25 Class::MOP::Class->initialize(blessed($_[0]) || $_[0]);
33 ('CODE' eq (reftype($code) || ''))
34 || confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
37 } => blessed($class) || $class;
42 sub body { (shift)->{'&!body'} }
44 # TODO - add associated_class
49 # this may not be the same name
50 # as the class you got it from
51 # This gets the package stash name
52 # associated with the actual CODE-ref
54 my $code = (shift)->body;
55 svref_2object($code)->GV->STASH->NAME;
59 # this may not be the same name
60 # as the method name it is stored
61 # with. This gets the name associated
62 # with the actual CODE-ref
64 my $code = (shift)->body;
65 svref_2object($code)->GV->NAME;
68 sub fully_qualified_name {
70 $code->package_name . '::' . $code->name;
81 Class::MOP::Method - Method Meta Object
85 # ... more to come later maybe
89 The Method Protocol is very small, since methods in Perl 5 are just
90 subroutines within the particular package. We provide a very basic
91 introspection interface.
101 This will return a B<Class::MOP::Class> instance which is related
110 =item B<wrap (&code)>
122 =item B<package_name>
124 =item B<fully_qualified_name>
130 Stevan Little E<lt>stevan@iinteractive.comE<gt>
132 =head1 COPYRIGHT AND LICENSE
134 Copyright 2006, 2007 by Infinity Interactive, Inc.
136 L<http://www.iinteractive.com>
138 This library is free software; you can redistribute it and/or modify
139 it under the same terms as Perl itself.