X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FPurePerl.pm;h=80537c91f202345647cc5622f161afc6a96b7637;hb=80efe91126e926233fade8bdd58288929286fc09;hp=e77f3129f2fe624cd98d8a3cfacb5b09c00606ce;hpb=ca861dd989ddc9868e5c69a39844e1e888bb9508;p=gitmo%2FMouse.git diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index e77f312..80537c9 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -97,6 +97,32 @@ sub generate_isa_predicate_for { return $predicate; } +sub generate_can_predicate_for { + my($methods_ref, $name) = @_; + + my @methods = @{$methods_ref}; + + my $predicate = sub{ + my($instance) = @_; + if(Scalar::Util::blessed($instance)){ + foreach my $method(@methods){ + if(!$instance->can($method)){ + return 0; + } + } + return 1; + } + return 0; + }; + + if(defined $name){ + no strict 'refs'; + *{ caller() . '::' . $name } = $predicate; + return; + } + + return $predicate; +} package Mouse::Util::TypeConstraints; @@ -291,6 +317,7 @@ sub _initialize_object{ return; } +sub is_immutable { $_[0]->{is_immutable} } package Mouse::Meta::Role; @@ -487,6 +514,24 @@ sub DESTROY { die $e if $e; # rethrow } +sub BUILDALL { + my $self = shift; + + # short circuit + return unless $self->can('BUILD'); + + for my $class (reverse $self->meta->linearized_isa) { + my $build = Mouse::Util::get_code_ref($class, 'BUILD') + || next; + + $self->$build(@_); + } + return; +} + +sub DEMOLISHALL; +*DEMOLISHALL = \&DESTROY; + 1; __END__ @@ -496,7 +541,7 @@ Mouse::PurePerl - A Mouse guts in pure Perl =head1 VERSION -This document describes Mouse version 0.42 +This document describes Mouse version 0.44 =head1 SEE ALSO