[Moose-commits] r7259 - in Moose/branches/meta-independence/lib: .
Moose/Meta Moose/Meta/Role/Application Moose/Util
sartak at code2.0beta.co.uk
sartak at code2.0beta.co.uk
Wed Jan 7 15:40:00 GMT 2009
Author: sartak
Date: 2009-01-07 07:40:00 -0800 (Wed, 07 Jan 2009)
New Revision: 7259
Modified:
Moose/branches/meta-independence/lib/Moose.pm
Moose/branches/meta-independence/lib/Moose/Meta/Attribute.pm
Moose/branches/meta-independence/lib/Moose/Meta/Role.pm
Moose/branches/meta-independence/lib/Moose/Meta/Role/Application/ToInstance.pm
Moose/branches/meta-independence/lib/Moose/Util/TypeConstraints.pm
Log:
Use Class::MOP::get_meta($thing) instead of $thing->meta
Modified: Moose/branches/meta-independence/lib/Moose/Meta/Attribute.pm
===================================================================
--- Moose/branches/meta-independence/lib/Moose/Meta/Attribute.pm 2009-01-07 15:39:45 UTC (rev 7258)
+++ Moose/branches/meta-independence/lib/Moose/Meta/Attribute.pm 2009-01-07 15:40:00 UTC (rev 7259)
@@ -249,7 +249,7 @@
} 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;
}
@@ -651,13 +651,10 @@
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,
@@ -671,7 +668,8 @@
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
@@ -681,7 +679,7 @@
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);
Modified: Moose/branches/meta-independence/lib/Moose/Meta/Role/Application/ToInstance.pm
===================================================================
--- Moose/branches/meta-independence/lib/Moose/Meta/Role/Application/ToInstance.pm 2009-01-07 15:39:45 UTC (rev 7258)
+++ Moose/branches/meta-independence/lib/Moose/Meta/Role/Application/ToInstance.pm 2009-01-07 15:40:00 UTC (rev 7259)
@@ -29,7 +29,7 @@
$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) ]
);
Modified: Moose/branches/meta-independence/lib/Moose/Meta/Role.pm
===================================================================
--- Moose/branches/meta-independence/lib/Moose/Meta/Role.pm 2009-01-07 15:39:45 UTC (rev 7258)
+++ Moose/branches/meta-independence/lib/Moose/Meta/Role.pm 2009-01-07 15:40:00 UTC (rev 7259)
@@ -321,19 +321,10 @@
$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:
@@ -462,7 +453,7 @@
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;
}
Modified: Moose/branches/meta-independence/lib/Moose/Util/TypeConstraints.pm
===================================================================
--- Moose/branches/meta-independence/lib/Moose/Util/TypeConstraints.pm 2009-01-07 15:39:45 UTC (rev 7258)
+++ Moose/branches/meta-independence/lib/Moose/Util/TypeConstraints.pm 2009-01-07 15:40:00 UTC (rev 7259)
@@ -490,7 +490,7 @@
# 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
Modified: Moose/branches/meta-independence/lib/Moose.pm
===================================================================
--- Moose/branches/meta-independence/lib/Moose.pm 2009-01-07 15:39:45 UTC (rev 7258)
+++ Moose/branches/meta-independence/lib/Moose.pm 2009-01-07 15:40:00 UTC (rev 7259)
@@ -49,11 +49,9 @@
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')
}
More information about the Moose-commits
mailing list