X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose.pm;h=ecba98c0c4d209499e3b606516c13e2753b25ac5;hb=1abd7f66ba40d740183fb4c74aaad79f43f667f3;hp=96b0b89c218b3f029d0c62e0ebb1b78979d4925a;hpb=546a8972e6139f438f00a3e82396ee51b6effe76;p=gitmo%2FMoose.git diff --git a/lib/Moose.pm b/lib/Moose.pm index 96b0b89..ecba98c 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -6,12 +6,19 @@ use 5.008; use Scalar::Util 'blessed'; use Carp 'confess'; +use Class::Load 'is_class_loaded'; + use Moose::Deprecated; use Moose::Exporter; use Class::MOP; +BEGIN { + die "Class::MOP version $Moose::VERSION required--this is version $Class::MOP::VERSION" + if $Moose::VERSION && $Class::MOP::VERSION ne $Moose::VERSION; +} + use Moose::Meta::Class; use Moose::Meta::TypeConstraint; use Moose::Meta::TypeCoercion; @@ -127,22 +134,6 @@ Moose::Exporter->setup_import_methods( ); sub init_meta { - # This used to be called as a function. This hack preserves - # backwards compatibility. - if ( $_[0] ne __PACKAGE__ ) { - Moose::Deprecated::deprecated( - feature => 'Moose::init_meta', - message => 'Calling Moose::init_meta as a function is deprecated.' - . ' Doing so will throw an error in Moose 2.0200.' - ); - - return __PACKAGE__->init_meta( - for_class => $_[0], - base_class => $_[1], - metaclass => $_[2], - ); - } - shift; my %args = @_; @@ -152,6 +143,9 @@ sub init_meta { my $metaclass = $args{metaclass} || 'Moose::Meta::Class'; my $meta_name = exists $args{meta_name} ? $args{meta_name} : 'meta'; + Moose->throw_error("The Metaclass $metaclass must be loaded. (Perhaps you forgot to 'use $metaclass'?)") + unless is_class_loaded($metaclass); + Moose->throw_error("The Metaclass $metaclass must be a subclass of Moose::Meta::Class.") unless $metaclass->isa('Moose::Meta::Class'); @@ -241,7 +235,6 @@ $_->make_immutable( Moose::Meta::TypeCoercion::Union Moose::Meta::Method - Moose::Meta::Method::Accessor Moose::Meta::Method::Constructor Moose::Meta::Method::Destructor Moose::Meta::Method::Overridden @@ -262,9 +255,17 @@ $_->make_immutable( Moose::Meta::Role::Application::ToInstance ); -Moose::Meta::Mixin::AttributeCore->meta->make_immutable( +$_->make_immutable( inline_constructor => 0, constructor_name => undef, + # these are Class::MOP accessors, so they need inlining + inline_accessors => 1 + ) for grep { $_->is_mutable } + map { $_->meta } + qw( + Moose::Meta::Method::Accessor + Moose::Meta::Method::Delegation + Moose::Meta::Mixin::AttributeCore ); 1; @@ -810,11 +811,8 @@ reasons. =head1 METACLASS -When you use Moose, you can specify which metaclass to use: - - use Moose -metaclass => 'My::Meta::Class'; - -You can also specify traits which will be applied to your metaclass: +When you use Moose, you can specify traits which will be applied to your +metaclass: use Moose -traits => 'My::Trait';