From: hdp Date: Wed, 30 Jan 2008 22:43:46 +0000 (+0000) Subject: switch interfaces to be less weird X-Git-Tag: 0.003~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fda3c8a5805adffdb67ce3a86f3ee85a6249f734;p=gitmo%2FMooseX-InsideOut.git switch interfaces to be less weird --- diff --git a/Changes b/Changes index 5a77371..d82496f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for MooseX-InsideOut +0.002 Wed, 30 Jan 2008 17:40:32 -0500 + + * get rid of the 'extends' interface, emulate MooseX::StrictConstructor + 0.001 Thu, 24 Jan 2008 13:17:54 -0500 * first release; thanks to stevan and mst for help diff --git a/lib/MooseX/InsideOut.pm b/lib/MooseX/InsideOut.pm index 4f993f5..2f0c41f 100644 --- a/lib/MooseX/InsideOut.pm +++ b/lib/MooseX/InsideOut.pm @@ -3,10 +3,31 @@ use warnings; package MooseX::InsideOut; -use metaclass 'MooseX::InsideOut::Meta::Class'; -use Moose; +use MooseX::InsideOut::Meta::Class; +BEGIN { require Moose } +use Carp; -our $VERSION = '0.001'; +our $VERSION = '0.002'; + +sub import { + my $class = shift; + + if (@_) { Carp::confess "$class has no exports" } + + my $into = caller; + + return if $into eq 'main'; + + Moose::init_meta( + $into, + 'Moose::Object', + 'MooseX::InsideOut::Meta::Class', + ); + + Moose->import({ into => $into }); + + return; +} 1; __END__ @@ -17,14 +38,13 @@ MooseX::InsideOut - inside-out objects with Moose =head1 VERSION -Version 0.001 +Version 0.002 =head1 SYNOPSIS package My::Object; - use Moose; - extends 'MooseX::InsideOut'; + use MooseX::InsideOut; # ... normal Moose functionality # or ... @@ -33,15 +53,16 @@ Version 0.001 use metaclass 'MooseX::InsideOut::Meta::Class'; use Moose; - extends 'Some::Other::Class; + extends 'Some::Other::Class'; =head1 DESCRIPTION MooseX::InsideOut provides a metaclass and an instance metaclass for inside-out objects. -You can use MooseX::InsideOut as a normal base class, as in the first example -in the L. +You can use MooseX::InsideOut, as in the first example in the L. +This sets up the metaclass and instance metaclass for you, as well as importing +all of the normal Moose goodies. You can also use the metaclass C directly, as in the second example. This is most useful when extending a non-Moose class, diff --git a/t/lib/InsideOut/BaseIO.pm b/t/lib/InsideOut/BaseIO.pm index 23311cc..4d93e6a 100644 --- a/t/lib/InsideOut/BaseIO.pm +++ b/t/lib/InsideOut/BaseIO.pm @@ -3,8 +3,7 @@ use warnings; package InsideOut::BaseIO; -use Moose; -extends 'MooseX::InsideOut'; +use MooseX::InsideOut; has base_foo => ( is => 'rw',