Moose taking advantage of the XS
[gitmo/Moose.git] / lib / Moose.pm
index b3073c4..b81aa74 100644 (file)
@@ -4,17 +4,16 @@ package Moose;
 use strict;
 use warnings;
 
-our $VERSION   = '0.30';
+our $VERSION   = '0.33';
 our $AUTHORITY = 'cpan:STEVAN';
 
 use Scalar::Util 'blessed', 'reftype';
 use Carp         'confess';
 use Sub::Name    'subname';
-use B            'svref_2object';
 
 use Sub::Exporter;
 
-use Class::MOP 0.43;
+use Class::MOP 0.46;
 
 use Moose::Meta::Class;
 use Moose::Meta::TypeConstraint;
@@ -36,12 +35,12 @@ use Moose::Util::TypeConstraints;
         $metaclass = 'Moose::Meta::Class' unless defined $metaclass;
 
         confess
-          "The Metaclass $metaclass must be a subclass of Moose::Meta::Class."
-          unless $metaclass->isa('Moose::Meta::Class');
+            "The Metaclass $metaclass must be a subclass of Moose::Meta::Class."
+            unless $metaclass->isa('Moose::Meta::Class');
 
         # make a subtype for each Moose class
         subtype $class => as 'Object' => where { $_->isa($class) } =>
-          optimize_as { blessed( $_[0] ) && $_[0]->isa($class) }
+            optimize_as { blessed( $_[0] ) && $_[0]->isa($class) }
         unless find_type_constraint($class);
 
         my $meta;
@@ -52,8 +51,7 @@ use Moose::Util::TypeConstraints;
             # override a specific class
             $meta = $class->meta();
             ( blessed($meta) && $meta->isa('Moose::Meta::Class') )
-              || confess
-"You already have a &meta function, but it does not return a Moose::Meta::Class";
+              || confess "You already have a &meta function, but it does not return a Moose::Meta::Class";
         }
         else {
             # NOTE:
@@ -162,32 +160,6 @@ use Moose::Util::TypeConstraints;
                 $class->meta->add_augment_method_modifier( $name => $method );
             };
         },
-
-        # NOTE:
-        # this is experimental, but I am not
-        # happy with it. If you want to try
-        # it, you will have to uncomment it
-        # yourself.
-        # There is a really good chance that
-        # this will be deprecated, dont get
-        # too attached
-        # self => sub {
-        #     return subname 'Moose::self' => sub {};
-        # },
-        # method => sub {
-        #     my $class = $CALLER;
-        #     return subname 'Moose::method' => sub {
-        #         my ($name, $method) = @_;
-        #         $class->meta->add_method($name, sub {
-        #             my $self = shift;
-        #             no strict   'refs';
-        #             no warnings 'redefine';
-        #             local *{$class->meta->name . '::self'} = sub { $self };
-        #             $method->(@_);
-        #         });
-        #     };
-        # },
-
         confess => sub {
             return \&Carp::confess;
         },
@@ -240,8 +212,7 @@ use Moose::Util::TypeConstraints;
                 my $keyword = \&{ $class . '::' . $name };
 
                 # make sure it is from Moose
-                my $pkg_name =
-                  eval { svref_2object($keyword)->GV->STASH->NAME };
+                my ($pkg_name) = Class::MOP::get_code_info($keyword);
                 next if $@;
                 next if $pkg_name ne 'Moose';
 
@@ -519,6 +490,11 @@ almost never want to do this, since it usually breaks your class. As with
 overriding locally defined methods, if you do want to do this, you should do it
 manually, not with Moose.
 
+You do not I<need> to have a reader (or accessor) for the attribute in order 
+to delegate to it. Moose will create a means of accessing the value for you, 
+however this will be several times B<less> efficient then if you had given 
+the attribute a reader (or accessor) to use.
+
 Below is the documentation for each option format:
 
 =over 4
@@ -896,6 +872,8 @@ Piotr (dexter) Roszatycki
 
 Sam (mugwump) Vilain
 
+Shawn (sartak) Moore
+
 ... and many other #moose folks
 
 =head1 COPYRIGHT AND LICENSE