X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FAutobox.pm;h=934b7a3d78c7adda47769f9df4943f94b9f11922;hb=ca2e2c86816f49d84218f96711dafd5e2e2c2a09;hp=59124646fe84187a29e70b412ceffc863ae0ac96;hpb=7e48618b1a3b1b39933c2f268abdd1b1b93adbfb;p=gitmo%2FMoose-Autobox.git diff --git a/lib/Moose/Autobox.pm b/lib/Moose/Autobox.pm index 5912464..934b7a3 100644 --- a/lib/Moose/Autobox.pm +++ b/lib/Moose/Autobox.pm @@ -1,13 +1,14 @@ package Moose::Autobox; - +use 5.006; use strict; use warnings; use Carp qw(confess); use Scalar::Util (); +use Moose::Util (); -our $VERSION = '0.05'; +our $VERSION = '0.08'; use base 'autobox'; @@ -24,7 +25,7 @@ sub mixin_additional_role { my ($class, $type, $role) = @_; ($type =~ /SCALAR|ARRAY|HASH|CODE/) || confess "Can only add additional roles to SCALAR, ARRAY, HASH or CODE"; - ('Moose::Autobox::' . $type)->meta->_apply_all_roles($role); + Moose::Util::apply_all_roles(('Moose::Autobox::' . $type)->meta, ($role)); } { @@ -35,7 +36,7 @@ sub mixin_additional_role { use metaclass 'Moose::Meta::Class'; - __PACKAGE__->meta->_apply_all_roles('Moose::Autobox::Scalar'); + Moose::Util::apply_all_roles(__PACKAGE__->meta, ('Moose::Autobox::Scalar')); *does = \&Moose::Object::does; @@ -45,7 +46,7 @@ sub mixin_additional_role { use metaclass 'Moose::Meta::Class'; - __PACKAGE__->meta->_apply_all_roles('Moose::Autobox::Array'); + Moose::Util::apply_all_roles(__PACKAGE__->meta, ('Moose::Autobox::Array')); *does = \&Moose::Object::does; @@ -55,7 +56,7 @@ sub mixin_additional_role { use metaclass 'Moose::Meta::Class'; - __PACKAGE__->meta->_apply_all_roles('Moose::Autobox::Hash'); + Moose::Util::apply_all_roles(__PACKAGE__->meta, ('Moose::Autobox::Hash')); *does = \&Moose::Object::does; @@ -65,7 +66,7 @@ sub mixin_additional_role { use metaclass 'Moose::Meta::Class'; - __PACKAGE__->meta->_apply_all_roles('Moose::Autobox::Code'); + Moose::Util::apply_all_roles(__PACKAGE__->meta, ('Moose::Autobox::Code')); *does = \&Moose::Object::does; @@ -79,7 +80,7 @@ __END__ =head1 NAME -Moose::Autobox - Ruby ain't got nothin on us +Moose::Autobox - Autoboxed wrappers for Native Perl datatypes =head1 SYNOPOSIS @@ -88,20 +89,6 @@ Moose::Autobox - Ruby ain't got nothin on us print 'Print squares from 1 to 10 : '; print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', '); -=head1 CAVEAT - -First, a warning. - -This module is very very very very very very very experimental. It -makes use of a very experimental module (L) and uses some -shiney new technology (L) to accomplish it's goals. - -Use this at your own risk. If it breaks the lamp in the living room -and your mother yells at you, don't come complaining to me. - -Also, as this is so experimental, it's API should not be considered -to be stable. It could very well change in radical ways. - =head1 DESCRIPTION Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH @@ -122,10 +109,27 @@ the 'hooks' for others to add implementation too. =head2 Is this for real? or just play? -My intent is to try and make this module as production worthy as -possible. This may or may not be possible, depending on how well -L works out. At this point, I have high hopes for things -but only time (and more tests and code) will tell. +Several people are using this module in serious applications and +it seems to be quite stable. The underlying technologies of L +and L are also considered stable. There is some performance +hit, but as I am fond of saying, nothing in life is free. If you have +any questions regarding this module, either email me, or stop by #moose +on irc.perl.org and ask around. + +=head2 Adding additional methods + +B asks L to use the B namespace +prefix so as to avoid stepping on the toes of other L modules. This +means that if you want to add methods to a particular perl type +(i.e. - monkeypatch), then you must do this: + + sub Moose::Autobox::SCALAR::bar { 42 } + +instead of this: + + sub SCALAR::bar { 42 } + +as you would with vanilla autobox. =head1 METHODS @@ -171,7 +175,7 @@ renormalist =head1 COPYRIGHT AND LICENSE -Copyright 2006-2007 by Infinity Interactive, Inc. +Copyright 2006-2008 by Infinity Interactive, Inc. L