use strict;
use warnings;
-our $VERSION = '0.28';
+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;
$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;
# 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:
$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;
},
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';
=head2 Moose Extensions
The L<MooseX::> namespace is the official place to find Moose extensions.
-There are a number of these modules out on CPAN right now the best way to
-find them is to search for MooseX:: on search.cpan.org.
+There are a number of these modules out on CPAN right now the best way to
+find them is to search for MooseX:: on search.cpan.org.
=head1 BUILDING CLASSES WITH MOOSE
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
Sam (mugwump) Vilain
+Shawn (sartak) Moore
+
... and many other #moose folks
=head1 COPYRIGHT AND LICENSE