From: Dave Rolsky Date: Sat, 8 Dec 2007 17:44:48 +0000 (+0000) Subject: Updates for 0.03. X-Git-Tag: 0.04~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-ClassAttribute.git;a=commitdiff_plain;h=8d65540448deca131e4c77686c6a1135116e522e Updates for 0.03. Split main functionality into separate sub which accepts a package as the first argument. Really, this should be part of a class metaclass, but that's an annoying road to go down. --- diff --git a/Changes b/Changes index d58661d..4cd1bb7 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,10 @@ +0.03 2007-12-08 + +- Split main functionality out of sugar sub class_has(), into + process_class_attribute(). This makes it easier to create attributes + on behalf of other classes. + + 0.02 2007-11-25 - Inherit from Exporter, rather than trying to import its diff --git a/lib/MooseX/ClassAttribute.pm b/lib/MooseX/ClassAttribute.pm index 9eb4d88..b7c6398 100644 --- a/lib/MooseX/ClassAttribute.pm +++ b/lib/MooseX/ClassAttribute.pm @@ -3,7 +3,7 @@ package MooseX::ClassAttribute; use strict; use warnings; -our $VERSION = '0.02'; +our $VERSION = '0.03'; our $AUTHORITY = 'cpan:DROLSKY'; our @EXPORT = 'class_has'; ## no critic ProhibitAutomaticExportation @@ -18,6 +18,15 @@ sub class_has ## no critic RequireArgUnpacking { my $caller = caller(); + process_class_attribute( $caller, @_ ); + + return; +} + +sub process_class_attribute ## no critic RequireArgUnpacking +{ + my $caller = shift; + my $caller_meta = $caller->meta(); my @parents = $caller_meta->superclasses(); @@ -85,7 +94,7 @@ sub class_has ## no critic RequireArgUnpacking } # This is basically copied from Moose.pm -sub unimport ## no critic RequireFinalReturn +sub unimport ## no critic RequireFinalReturn, RequireArgUnpacking { my $caller = Moose::_get_caller(@_); @@ -166,6 +175,16 @@ Own little nit is that if you include C in your class, you won't remove the C function. To do that you must include C as well. +If you want to use this module to create class attributes in I +classes, you can call the C function like +this: + + MooseX::ClassAttribute::process_class_attribute( $package, ... ); + +The first argument is the package which will have the class attribute, +and the remaining arguments are the same as those passed to +C. + =head2 Implementation and Immutability Underneath the hood, this class creates one new class for each class diff --git a/t/pod-coverage.t b/t/pod-coverage.t index 517c730..4005e5e 100644 --- a/t/pod-coverage.t +++ b/t/pod-coverage.t @@ -11,4 +11,4 @@ eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; -all_pod_coverage_ok( { trustme => [ qr/^(?:class_has|container_class|unimport)$/ ] } ); +all_pod_coverage_ok( { trustme => [ qr/^(?:class_has|process_class_attribute|container_class|unimport)$/ ] } );