[Moose-commits] r7463 - in MooseX-ExtendsNonMoose/trunk: eg
lib/MooseX
dexter at code2.0beta.co.uk
dexter at code2.0beta.co.uk
Sun Feb 1 12:57:33 GMT 2009
Author: dexter
Date: 2009-02-01 04:57:33 -0800 (Sun, 01 Feb 2009)
New Revision: 7463
Added:
MooseX-ExtendsNonMoose/trunk/eg/path_class_dir.pl
Modified:
MooseX-ExtendsNonMoose/trunk/eg/file_temp_jpg.pl
MooseX-ExtendsNonMoose/trunk/lib/MooseX/ExtendsNonMoose.pm
Log:
* SUPERBUILDARG returns ArrayRef.
* Another example.
Modified: MooseX-ExtendsNonMoose/trunk/eg/file_temp_jpg.pl
===================================================================
--- MooseX-ExtendsNonMoose/trunk/eg/file_temp_jpg.pl 2009-02-01 11:42:46 UTC (rev 7462)
+++ MooseX-ExtendsNonMoose/trunk/eg/file_temp_jpg.pl 2009-02-01 12:57:33 UTC (rev 7463)
@@ -11,12 +11,13 @@
extends 'File::Temp', 'MooseX::GlobRef::Object';
extends_non_moose;
+use constant::boolean;
+
has 'SUFFIX' => (is => 'ro', isa => 'Str');
-has 'UNLINK' => (is => 'ro', isa => 'Bool');
sub new_with_suffix {
my $class = shift;
- return $class->new( SUFFIX => '.jpg', @_ );
+ return $class->new( UNLINK => FALSE, SUFFIX => '.jpg', @_ );
};
Property changes on: MooseX-ExtendsNonMoose/trunk/eg/file_temp_jpg.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: MooseX-ExtendsNonMoose/trunk/eg/path_class_dir.pl
===================================================================
--- MooseX-ExtendsNonMoose/trunk/eg/path_class_dir.pl (rev 0)
+++ MooseX-ExtendsNonMoose/trunk/eg/path_class_dir.pl 2009-02-01 12:57:33 UTC (rev 7463)
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use lib 'lib', '../lib';
+
+
+package My::Path::Class::Dir;
+
+use Moose;
+use MooseX::ExtendsNonMoose;
+
+extends 'Path::Class::Dir';
+extends_non_moose;
+
+has path => (is => 'ro', isa => 'Str | ArrayRef[Str]');
+has dirs => (is => 'ro', isa => 'ArrayRef[Str]');
+
+sub SUPERBUILDARGS {
+ my $class = shift;
+ my %args = @_;
+ return ref $args{path} eq 'ARRAY' ? $args{path} : [ $args{path} ];
+};
+
+sub basename {
+ my $self = shift;
+ my $dirs = $self->dirs;
+ return $dirs->[scalar @$dirs - 1];
+};
+
+
+package main;
+
+my $dir = My::Path::Class::Dir->new( path => '/usr/local/lib/site_perl' );
+my $basename = $dir->basename;
+print "Base name or $dir is $basename\n";
Property changes on: MooseX-ExtendsNonMoose/trunk/eg/path_class_dir.pl
___________________________________________________________________
Name: svn:executable
+ *
Modified: MooseX-ExtendsNonMoose/trunk/lib/MooseX/ExtendsNonMoose.pm
===================================================================
--- MooseX-ExtendsNonMoose/trunk/lib/MooseX/ExtendsNonMoose.pm 2009-02-01 11:42:46 UTC (rev 7462)
+++ MooseX-ExtendsNonMoose/trunk/lib/MooseX/ExtendsNonMoose.pm 2009-02-01 12:57:33 UTC (rev 7463)
@@ -82,12 +82,12 @@
my $super_constructor = $for_class->meta->find_next_method_by_name($constructor)->body
or Moose->throw_error("Can't locate object method ($constructor) via package ($for_class)");
- my @args = $class->can('SUPERBUILDARGS') ? $class->SUPERBUILDARGS(@_) : (@_);
+ my $superargs = $class->can('SUPERBUILDARGS') ? $class->SUPERBUILDARGS(@_) : [@_];
my $self = $class->meta->new_object(
# pass in the constructed object
# using the special key __INSTANCE__
- __INSTANCE__ => $super_constructor->($class, @args),
+ __INSTANCE__ => $super_constructor->($class, @$superargs),
@_, # pass in the normal args
);
More information about the Moose-commits
mailing list