some refactoring of handles
[gitmo/Moose.git] / lib / Moose.pm
index caf7c2c..ecc8801 100644 (file)
@@ -4,15 +4,15 @@ package Moose;
 use strict;
 use warnings;
 
-our $VERSION   = '0.45';
+our $VERSION   = '0.55';
 our $AUTHORITY = 'cpan:STEVAN';
 
-use Scalar::Util 'blessed', 'reftype';
+use Scalar::Util 'blessed';
 use Carp         'confess', 'croak', 'cluck';
 
 use Sub::Exporter;
 
-use Class::MOP 0.56;
+use Class::MOP;
 
 use Moose::Meta::Class;
 use Moose::Meta::TypeConstraint;
@@ -79,13 +79,19 @@ use Moose::Util ();
         extends => sub {
             my $class = $CALLER;
             return Class::MOP::subname('Moose::extends' => sub (@) {
-                confess "Must derive at least one class" unless @_;
+                croak "Must derive at least one class" unless @_;
         
                 my @supers = @_;
                 foreach my $super (@supers) {
                     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')
                 }
 
+
+
                 # this checks the metaclass to make sure
                 # it is correct, sometimes it can get out
                 # of sync when the classes are being built
@@ -128,12 +134,10 @@ use Moose::Util ();
             });
         },
         super => sub {
-            # FIXME can be made into goto, might break caller() for existing code
-            return Class::MOP::subname('Moose::super' => sub { return unless our $SUPER_BODY; $SUPER_BODY->(our @SUPER_ARGS) })
+            return Class::MOP::subname('Moose::super' => sub { 
+                return unless our $SUPER_BODY; $SUPER_BODY->(our @SUPER_ARGS) 
+            });
         },
-        #next => sub {
-        #    return subname 'Moose::next' => sub { @_ = our @SUPER_ARGS; goto \&next::method };
-        #},
         override => sub {
             my $class = $CALLER;
             return Class::MOP::subname('Moose::override' => sub ($&) {
@@ -190,11 +194,11 @@ use Moose::Util ();
     sub _get_caller{
         my $offset = 1;
         return
-            ref $_[1] && defined $_[1]->{into}
-            ? $_[1]->{into}
-            : ref $_[1] && defined $_[1]->{into_level}
-            ? caller($offset + $_[1]->{into_level})
-            : caller($offset);
+            (ref $_[1] && defined $_[1]->{into})
+                ? $_[1]->{into}
+                : (ref $_[1] && defined $_[1]->{into_level})
+                    ? caller($offset + $_[1]->{into_level})
+                    : caller($offset);
     }
 
     sub import {
@@ -215,6 +219,21 @@ use Moose::Util ();
 
         goto $exporter;
     }
+    
+    # NOTE:
+    # This is for special use by 
+    # some modules and stuff, I 
+    # dont know if it is sane enough
+    # to document actually.
+    # - SL
+    sub __CURRY_EXPORTS_FOR_CLASS__ {
+        $CALLER = shift;
+        ($CALLER ne 'Moose')
+            || croak "_import_into must be called a function, not a method";
+        ($CALLER->can('meta') && $CALLER->meta->isa('Class::MOP::Class'))
+            || croak "Cannot call _import_into on a package ($CALLER) without a metaclass";        
+        return map { $_ => $exports{$_}->() } (@_ ? @_ : keys %exports);
+    }
 
     sub unimport {
         no strict 'refs';
@@ -960,6 +979,15 @@ All complex software has bugs lurking in it, and this module is no
 exception. If you find a bug please either email me, or add the bug
 to cpan-RT.
 
+=head1 FEATURE REQUESTS
+
+We are very strict about what features we add to the Moose core, especially 
+the user-visible features. Instead we have made sure that the underlying 
+meta-system of Moose is as extensible as possible so that you can add your 
+own features easily. That said, occasionally there is a feature needed in the 
+meta-system to support your planned extension, in which case you should 
+either email the mailing list or join us on irc at #moose to discuss.
+
 =head1 AUTHOR
 
 Stevan Little E<lt>stevan@iinteractive.comE<gt>
@@ -998,6 +1026,8 @@ Yuval (nothingmuch) Kogman
 
 Chris (perigrin) Prather
 
+Wallace (wreis) Reis
+
 Jonathan (jrockway) Rockway
 
 Piotr (dexter) Roszatycki