2 package Class::MOP::Method;
8 use Scalar::Util 'reftype', 'blessed';
9 #use B 'svref_2object';
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 (Class::MOP::get_code_info($code))[0];
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 (Class::MOP::get_code_info($code))[1];
68 sub fully_qualified_name {
70 $code->package_name . '::' . $code->name;
81 Class::MOP::Method - Method Meta Object
85 The Method Protocol is very small, since methods in Perl 5 are just
86 subroutines within the particular package. We provide a very basic
87 introspection interface.
97 This will return a B<Class::MOP::Class> instance which is related
106 =item B<wrap ($code)>
108 This is the basic constructor, it returns a B<Class::MOP::Method>
109 instance which wraps the given C<$code> reference.
119 This returns the actual CODE reference of the particular instance.
123 This returns the name of the CODE reference.
125 =item B<package_name>
127 This returns the package name that the CODE reference is attached to.
129 =item B<fully_qualified_name>
131 This returns the fully qualified name of the CODE reference.
137 Stevan Little E<lt>stevan@iinteractive.comE<gt>
139 =head1 COPYRIGHT AND LICENSE
141 Copyright 2006-2008 by Infinity Interactive, Inc.
143 L<http://www.iinteractive.com>
145 This library is free software; you can redistribute it and/or modify
146 it under the same terms as Perl itself.