my @supers = @_;
foreach my $super (@supers) {
- Class::MOP::load_class($super);
+ my $meta = Class::MOP::load_class($super);
croak "You cannot inherit from a Moose Role ($super)"
- if $super->can('meta') &&
- blessed $super->meta &&
- $super->meta->isa('Moose::Meta::Role')
+ if $meta && $meta->isa('Moose::Meta::Role')
}
} else {
my ( @init, @non_init );
- foreach my $attr ( grep { $_->has_value($self) } $self->meta->compute_all_applicable_attributes ) {
+ foreach my $attr ( grep { $_->has_value($self) } Class::MOP::get_meta($self)->compute_all_applicable_attributes ) {
push @{ $attr->has_init_arg ? \@init : \@non_init }, $attr;
}
Class::MOP::load_class($handles)
unless Class::MOP::is_class_loaded($handles);
- my $role_meta = eval { $handles->meta };
- if ($@) {
- $self->throw_error("Unable to canonicalize the 'handles' option with $handles because : $@", data => $handles, error => $@);
- }
+ my $role_meta = Class::MOP::get_meta($handles);
(blessed $role_meta && $role_meta->isa('Moose::Meta::Role'))
- || $self->throw_error("Unable to canonicalize the 'handles' option with $handles because ->meta is not a Moose::Meta::Role", data => $handles);
+ || $self->throw_error("Unable to canonicalize the 'handles' option with $handles because its metaclass is not a Moose::Meta::Role", data => $handles);
return map { $_ => $_ } (
$role_meta->get_method_list,
if (my $class = $self->_isa_metadata) {
# if the class does have
# a meta method, use it
- return $class->meta if $class->can('meta');
+ my $meta = Class::MOP::get_meta($class);
+ return $meta if $meta;
# otherwise we might be
# dealing with a non-Moose
# class, and need to make
elsif (my $role = $self->_does_metadata) {
# our role will always have
# a meta method
- return $role->meta;
+ return Class::MOP::get_meta($role);
}
else {
$self->throw_error("Cannot find delegate metaclass for attribute " . $self->name);
$map->{$symbol}->body == $code;
my ($pkg, $name) = Class::MOP::get_code_info($code);
+ my $meta = Class::MOP::get_meta($pkg);
- if ($pkg->can('meta')
- # NOTE:
- # we don't know what ->meta we are calling
- # here, so we need to be careful cause it
- # just might blow up at us, or just complain
- # loudly (in the case of Curses.pm) so we
- # just be a little overly cautious here.
- # - SL
- && eval { no warnings; blessed($pkg->meta) } # FIXME calls meta
- && $pkg->meta->isa('Moose::Meta::Role')) {
- my $role = $pkg->meta->name;
- next unless $self->does_role($role);
+ if ($meta && $meta->isa('Moose::Meta::Role')) {
+ next unless $self->does_role($meta->name);
}
else {
# NOTE:
my (@roles, %role_params);
while (@role_specs) {
my ($role, $params) = @{ splice @role_specs, 0, 1 };
- push @roles => $role->meta;
+ push @roles => Class::MOP::get_meta($role);
next unless defined $params;
$role_params{$role} = $params;
}
$class = $ANON_CLASSES{$anon_role_key};
}
else {
- my $obj_meta = eval { $object->meta } || 'Moose::Meta::Class';
+ my $obj_meta = Class::MOP::get_meta($object) || 'Moose::Meta::Class';
$class = $obj_meta->create_anon_class(
superclasses => [ blessed($object) ]
);
# these are Class::MOP accessors, so they need inlining
inline_accessors => 1
) for grep { $_->is_mutable }
- map { $_->meta }
+ map { Class::MOP::get_meta($_) }
qw(
Moose::Meta::TypeConstraint
Moose::Meta::TypeConstraint::Union