Only add metaroles if in new Moose
[gitmo/MooseX-SemiAffordanceAccessor.git] / lib / MooseX / SemiAffordanceAccessor.pm
index e951a5f..dac4a6d 100644 (file)
@@ -3,48 +3,35 @@ package MooseX::SemiAffordanceAccessor;
 use strict;
 use warnings;
 
-our $VERSION = '0.03';
-
-use Moose 0.5504 ();
+use Moose 0.94 ();
 use Moose::Exporter;
 use Moose::Util::MetaRole;
 use MooseX::SemiAffordanceAccessor::Role::Attribute;
 
-# The main reason to use this is to ensure that we get the right value
-# in $p{for_class} later.
-Moose::Exporter->setup_import_methods();
-
-
-sub init_meta
-{
-    shift;
-    my %p = @_;
-
-    Moose->init_meta(%p);
+my %metaroles = (
+    class_metaroles => {
+        attribute => ['MooseX::SemiAffordanceAccessor::Role::Attribute'],
+    },
+);
 
-    return
-        Moose::Util::MetaRole::apply_metaclass_roles
-            ( for_class => $p{for_class},
-              attribute_metaclass_roles =>
-              ['MooseX::SemiAffordanceAccessor::Role::Attribute'],
-            );
-}
+$metaroles{role_metaroles} = {
+    applied_attribute => ['MooseX::SemiAffordanceAccessor::Role::Attribute'],
+} if $Moose::VERSION >= 1.9900;
 
+Moose::Exporter->setup_import_methods(%metaroles);
 
 1;
 
+# ABSTRACT: Name your accessors foo() and set_foo()
+
 __END__
 
 =pod
 
-=head1 NAME
-
-MooseX::SemiAffordanceAccessor - Name your accessors foo() and set_foo()
-
 =head1 SYNOPSIS
 
-    use MooseX::SemiAffordanceAccessor;
     use Moose;
+    use MooseX::SemiAffordanceAccessor;
 
     # make some attributes
 
@@ -64,9 +51,18 @@ attribute, then that attribute's naming scheme is left unchanged.
 The name "semi-affordance" comes from David Wheeler's Class::Meta
 module.
 
-=head1 AUTHOR
+=head1 ACCESSORS IN ROLES
+
+Prior to version 1.9900 of L<Moose>, attributes added to a class ended up with
+that class's attribute traits. That means that if your class used
+C<MooseX::SemiAffordanceAccessor>, any attributes provided by roles you
+consumed had the semi-affordance style of accessor.
 
-Dave Rolsky, C<< <autarch@urth.org> >>
+As of Moose 1.9900, that is no longer the case. Attributes provided by roles
+no longer acquire the consuming class's attribute traits. However, with Moose
+1.9900+, you can now use C<MooseX::SemiAffordanceAccessor> directly in
+roles. Attributes defined by that role will have semi-affordance style
+accessors, regardless of what attribute traits the consuming class has.
 
 =head1 BUGS
 
@@ -76,11 +72,4 @@ the web interface at L<http://rt.cpan.org>.  I will be notified, and
 then you'll automatically be notified of progress on your bug as I
 make changes.
 
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2007 Dave Rolsky, All Rights Reserved.
-
-This program is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
 =cut