1 package Moose::Meta::Method::Does;
6 use Scalar::Util 'blessed', 'weaken', 'looks_like_number', 'refaddr';
9 our $AUTHORITY = 'cpan:STEVAN';
11 use base 'Moose::Meta::Method',
12 'Class::MOP::Method::Inlined';
18 my $meta = $options{metaclass};
20 ( ref $options{options} eq 'HASH' )
21 || $class->throw_error( "You must pass a hash of options",
22 data => $options{options} );
24 $options{package_name}
25 || $class->throw_error(
26 "You must supply the package_name parameter" );
30 'package_name' => $options{package_name},
32 'options' => $options{options},
33 'associated_metaclass' => $meta,
34 '_expected_method_class' => $options{_expected_method_class}
38 weaken( $self->{'associated_metaclass'} );
40 $self->_initialize_body;
45 sub _initialize_body {
52 . $self->_inline_throw_error(
53 q{"You must supply a role name to does()"});
54 $source .= ";\n" . 'my $name = Scalar::Util::blessed( $_[1] ) ? $_[1]->name : $_[1]';
55 $source .= ";\n" . 'return $does{$name} || 0';
56 $source .= ";\n" . '}';
58 my %does = map { $_->name => 1 }
59 $self->associated_metaclass->calculate_all_roles_with_inheritance;
61 my ( $code, $e ) = $self->_compile_code(
70 "Could not eval the does method :\n\n$source\n\nbecause :\n\n$e",
75 $self->{'body'} = $code;
86 Moose::Meta::Method::Constructor - Method Meta Object for constructors
90 This class is a subclass of L<Class::MOP::Method::Constructor> that
91 provides additional Moose-specific functionality
93 To understand this class, you should read the the
94 L<Class::MOP::Method::Constructor> documentation as well.
98 C<Moose::Meta::Method::Constructor> is a subclass of
99 L<Moose::Meta::Method> I<and> L<Class::MOP::Method::Constructor>.
103 See L<Moose/BUGS> for details on reporting bugs.
107 Stevan Little E<lt>stevan@iinteractive.comE<gt>
109 =head1 COPYRIGHT AND LICENSE
111 Copyright 2006-2010 by Infinity Interactive, Inc.
113 L<http://www.iinteractive.com>
115 This library is free software; you can redistribute it and/or modify
116 it under the same terms as Perl itself.