Checking in changes prior to tagging of version 0.40_04. Changelog diff is:
[gitmo/Mouse.git] / lib / Mouse.pm
index 0e12516..0326532 100644 (file)
@@ -1,13 +1,12 @@
 package Mouse;
 use 5.006_002;
 
-use strict;
-use warnings;
+use Mouse::Exporter; # enables strict and warnings
 
-our $VERSION = '0.37_02';
+our $VERSION = '0.40_04';
 
-use Carp qw(confess);
-use Scalar::Util ();
+use Carp         qw(confess);
+use Scalar::Util qw(blessed);
 
 use Mouse::Util qw(load_class is_class_loaded get_code_package not_supported);
 
@@ -17,7 +16,6 @@ use Mouse::Meta::Role;
 use Mouse::Meta::Attribute;
 use Mouse::Object;
 use Mouse::Util::TypeConstraints ();
-use Mouse::Exporter;
 
 Mouse::Exporter->setup_import_methods(
     as_is => [qw(
@@ -32,12 +30,25 @@ Mouse::Exporter->setup_import_methods(
    ],
 );
 
+# XXX: for backward compatibility
+our @EXPORT = qw(
+    extends with
+    has
+    before after around
+    override super
+    augment  inner
+    blessed confess
+);
+
 sub extends { Mouse::Meta::Class->initialize(scalar caller)->superclasses(@_) }
 
 sub has {
     my $meta = Mouse::Meta::Class->initialize(scalar caller);
     my $name = shift;
 
+    $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )})\r
+        if @_ % 2; # odd number of arguments
+
     $meta->add_attribute($_ => @_) for ref($name) ? @{$name} : $name;
 }
 
@@ -119,13 +130,10 @@ sub init_meta {
 
     my $class = $args{for_class}
                     or confess("Cannot call init_meta without specifying a for_class");
+
     my $base_class = $args{base_class} || 'Mouse::Object';
     my $metaclass  = $args{metaclass}  || 'Mouse::Meta::Class';
 
-    # make a subtype for each Mouse class
-    Mouse::Util::TypeConstraints::class_type($class)
-        unless Mouse::Util::TypeConstraints::find_type_constraint($class);
-
     my $meta = $metaclass->initialize($class);
 
     $meta->add_method(meta => sub{
@@ -135,18 +143,25 @@ sub init_meta {
     $meta->superclasses($base_class)
         unless $meta->superclasses;
 
+    # make a class type for each Mouse class
+    Mouse::Util::TypeConstraints::class_type($class)
+        unless Mouse::Util::TypeConstraints::find_type_constraint($class);
+
     return $meta;
 }
 
 
 1;
-
 __END__
 
 =head1 NAME
 
 Mouse - Moose minus the antlers
 
+=head1 VERSION
+
+This document describes Mouse version 0.40_04
+
 =head1 SYNOPSIS
 
     package Point;
@@ -187,9 +202,8 @@ latter, if possible.
 Mouse aims to alleviate this by providing a subset of Moose's functionality,
 faster.
 
-We're also going as light on dependencies as possible.
-L<Class::Method::Modifiers::Fast> or L<Class::Method::Modifiers> is required
-if you want support for L</before>, L</after>, and L</around>.
+We're also going as light on dependencies as possible. Mouse currently has
+B<no dependencies> except for testing modules.
 
 =head2 MOOSE COMPATIBILITY
 
@@ -209,6 +223,8 @@ Moose, if you run into weird errors, it would be worth running:
 to see if the bug is caused by Mouse. Moose's diagnostics and validation are
 also much better.
 
+See also L<Mouse::Spec> for compatibility and incompatibility with Moose.
+
 =head2 MouseX
 
 Please don't copy MooseX code to MouseX. If you need extensions, you really
@@ -384,6 +400,8 @@ Perl 5.6.2 or later.
 
 =head1 SEE ALSO
 
+L<Mouse::Spec>
+
 L<Moose>
 
 L<Class::MOP>