Revision history for Perl extension Moose
+0.44 Sat. May 10, 2008
* Moose
- - made make_immutable warning cluck to show where the error is
-
-0.44
+ - made make_immutable warning cluck to
+ show where the error is
+
+ * Moose::Object
+ - BUILDALL and DEMOLISHALL now call
+ ->body when looping through the
+ methods, to avoid the overloaded
+ method call.
+
* Moose::Cookbook::Recipe7
- - added new recipe for immutable functionality (Dave Rolsky)
+ - added new recipe for immutable
+ functionality (thanks Dave Rolsky)
+
* Moose::Cookbook::Recipe9
- - added new recipe for builder and lazy_build (Dave Rolsky)
+ - added new recipe for builder and
+ lazy_build (thanks Dave Rolsky)
+
* Moose::Cookbook::Recipe1
- - added new recipe for method aliasing and exclusion with Roles (Dave Rolsky)
+ - added new recipe for method aliasing
+ and exclusion with Roles (thanks Dave Rolsky)
+
+ * t/
+ - fixed Win32 test failure
0.43 Wed. April, 30, 2008
* NOTE TO SELF:
Build.PL
Changes
doap.rdf
+inc/Module/AutoInstall.pm
inc/Module/Install.pm
+inc/Module/Install/AutoInstall.pm
inc/Module/Install/Base.pm
inc/Module/Install/Build.pm
inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
+inc/Module/Install/Include.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Win32.pm
t/100_bugs/009_augment_recursion_bug.t
t/100_bugs/010_immutable_n_default_x2.t
t/100_bugs/011_DEMOLISH_eats_exceptions.t
+t/100_bugs/012_DEMOLISH_eats_mini.t
t/200_examples/001_example.t
t/200_examples/002_example_Moose_POOP.t
t/200_examples/003_example.t
-Moose version 0.41
+Moose version 0.44
===========================
See the individual module documentation for more information
use strict;
use warnings;
-our $VERSION = '0.43';
+our $VERSION = '0.44';
our $AUTHORITY = 'cpan:STEVAN';
use Scalar::Util 'blessed', 'reftype';
=head2 Another object system!?!?
Yes, I know there has been an explosion recently of new ways to
-build object's in Perl 5, most of them based on inside-out objects
+build objects in Perl 5, most of them based on inside-out objects
and other such things. Moose is different because it is not a new
object system for Perl 5, but instead an extension of the existing
object system.
-#!/usr/bin/env perl
+
=pod
=head1 NAME
-Moose::Cookbook::Snack::ArrayRef - (Ab)using the ArrayRef type constraint
-provided by the L<Moose::Util::TypeConstraint> and/or
-L<Moose::Util::TypeConstraints::OptimizedConstraints> classes.
+Moose::Cookbook::Snack::ArrayRef - Using the ArrayRef type constraint
=head1 SYNOPSIS
sub show_inventory {
my $self = shift;
foreach my $item ( @{$self->fruit_aisle} ) {
- # access each Fruit object
- } # foreach my $item ( @{$self->fruit_aisle} )
+ # ... access each Fruit object
+ }
}
=head2 Assigning arrays to an ArrayRef will overwrite existing arrays
for my $fruit_obj ( @fruit_aisle_copy ) {
if ( $fruit_obj->name ne 'tomato' ) {
push(@reworked_fruit_aisle, $fruit_obj);
- } # if ( $fruit_obj->name ne 'tomato' )
- } # for my $fruit_obj ( @fruit_aisle_copy )
+ }
+ }
$store->fruit_aisle( \@reworked_fruit_aisle );
Putting the above code into their own object methods would make appending to or deleting from an C<ArrayRef> a trivial operation.
Type Constraints
=item L<Moose::Util::TypeConstraints> - Type constraints that Moose can use
+and the tools to extend them or create your own.
=item L<Moose::Autobox> - Autoboxed wrappers for Native Perl datatypes
=head1 COPYRIGHT AND LICENSE
-Copyright (c)2008 by Infinity Interactive, Inc., Brian Manning
+Copyright 2006-2008 by Infinity Interactive, Inc.
+
+L<http://www.iinteractive.com>
-This documentation is free software; you can redistribute it and/or modify
+This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
-#!/usr/bin/env perl
+
=pod
=head1 NAME
-Moose::Cookbook::Snack::HashRef - (Ab)using the HashRef type constraint
-provided by the L<Moose::Util::TypeConstraint> and/or
-L<Moose::Util::TypeConstraints::OptimizedConstraints> classes.
+Moose::Cookbook::Snack::HashRef - Using the HashRef type constraint
=head1 SYNOPSIS
The code in this document will work on Moose as advertised, but the developers
strongly recommend using something like L<Moose::Autobox> or
-L<MooseX::AttributeHelpers> when working with array references in order to
+L<MooseX::AttributeHelpers> when working with hash references in order to
help keep your Moose objects nice and encapsulated.
=head2 Assigning hashes to a HashRef attribute
my $fruit = $self->{fruit_aisle}{$item};
print "Item: $item, type: " . $fruit->meta->name
. " species: " . $fruit->species . "\n";
- } # foreach my $item
+ }
If the above de-referencing of the C<fruit_aisle> C<HashRef> is a little too
noisy, you could create a copy of it, and then enumerate over that copy:
my %fruit_aisle_copy = %{$self->fruit_aisle};
foreach my $item ( keys(%fruit_aisle_copy) ) {
my $fruit = $fruit_aisle_copy{$item};
- # 'print' statement from above example goes here
+ print "Item: $item, type: " . $fruit->meta->name
+ . " species: " . $fruit->species . "\n";
}
=head2 Assigning to a HashRef attribute will overwrite
=item L<Moose::Cookbook::Snack::Types> - Snippets of code for using Types and
Type Constraints
-=item L<Moose::Util::TypeConstraints> - Type constraints system for Moose
+=item L<Moose::Util::TypeConstraints> - Type constraints that Moose can use
+and the tools to extend them or create your own.
+
+=item L<Moose::Autobox> - Autoboxed wrappers for Native Perl datatypes
+
+=item L<MooseX::AttributeHelpers> - Extends attribute interfaces
=back
=head1 COPYRIGHT AND LICENSE
-Copyright (c)2008 by Infinity Interactive, Inc., Brian Manning
+Copyright 2006-2008 by Infinity Interactive, Inc.
+
+L<http://www.iinteractive.com>
-This documentation is free software; you can redistribute it and/or modify
+This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# verify that the user passed in the 'script_name' attribute
if ( exists $args{script_name} ) {
$self->script_name($args{script_name});
- } else {
+ }
+ else {
die "ERROR: can't create object without 'script_name' ";
- } # if ( exists $args{script_name} )
+ }
# return the object reference back to the caller
return $self;
- } # sub new
+ }
sub script_name {
my $self = shift;
- # check for arguments; use the argument if passed in, otherwise
- # return the existing value (if any)
- if (@_) { $self->{script_name} = shift }
+ # check for arguments; use the argument
+ # if passed in, otherwise return the
+ # existing value (if any)
+ if (@_) {
+ $self->{script_name} = shift;
+ }
return $self->{script_name};
- } # sub script_name
+ }
package main;
use strict;
=item L<Moose::Cookbook::Recipe1> - The 'Point' object example
=item L<Moose::Util::TypeConstraints> - Type constraints that Moose can use
+and the tools to extend them or create your own.
=item L<Moose::Cookbook::WTF> - For when things go wrong with Moose
=head1 COPYRIGHT AND LICENSE
-Copyright (c)2008 by Infinity Interactive, Inc., Brian Manning
+Copyright 2006-2008 by Infinity Interactive, Inc.
-This documentation is free software; you can redistribute it and/or modify
+L<http://www.iinteractive.com>
+
+This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
use Carp 'confess';
-our $VERSION = '0.12';
+our $VERSION = '0.13';
our $AUTHORITY = 'cpan:STEVAN';
sub new {
}
sub DEMOLISHALL {
+ my $self = shift;
+ foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
+ $method->{code}->body->($self);
+ }
+}
+
+sub DESTROY {
# NOTE: we ask Perl if we even
# need to do this first, to avoid
# extra meta level calls
- return unless $_[0]->can('DEMOLISH');
- my $self = shift;
- {
- local $@;
- foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
- $method->{code}->body->($self);
- }
- }
+ return unless $_[0]->can('DEMOLISH');
+ # if we have an exception here ...
+ if (my $e = $@) {
+ # run DEMOLISHALL ourselves, ...
+ (shift)->DEMOLISHALL;
+ # then restore the exception ...
+ $@ = $e;
+ # and return ...
+ return;
+ }
+ goto &DEMOLISHALL
}
-sub DESTROY { goto &DEMOLISHALL }
-
# new does() methods will be created
# as approiate see Moose::Meta::Role
sub does {
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More no_plan => 1;
+use Test::Exception;
+
+BEGIN {
+ use_ok('Moose');
+ use_ok('Moose::Util::TypeConstraints');
+}
+
+{
+ package Foo;
+ use Moose;
+
+ has 'bar' => (
+ is => 'ro',
+ required => 1,
+ );
+
+ # Defining this causes the FIRST call to Baz->new w/o param to fail,
+ # if no call to ANY Moose::Object->new was done before.
+ sub DEMOLISH {
+ my ( $self ) = @_;
+ }
+}
+
+my $obj = eval { Foo->new; };
+::like( $@, qr/is required/, "... Foo plain" );
+::is( $obj, undef, "... the object is undef" );
+
+1;
+