Moose 2.0 ready
[gitmo/MooseX-ClassAttribute.git] / lib / MooseX / ClassAttribute / Trait / Attribute.pm
index e0086a3..435842d 100644 (file)
@@ -3,10 +3,6 @@ package MooseX::ClassAttribute::Trait::Attribute;
 use strict;
 use warnings;
 
-our $VERSION   = '0.13';
-
-use MooseX::ClassAttribute::Meta::Method::Accessor;
-
 use namespace::autoclean;
 use Moose::Role;
 
@@ -14,10 +10,6 @@ use Moose::Role;
 # because it overrides a lot of behavior. However, as a subclass it
 # won't cooperate with _other_ subclasses.
 
-around 'accessor_metaclass' => sub {
-    return 'MooseX::ClassAttribute::Meta::Method::Accessor';
-};
-
 around '_process_options' => sub {
     my $orig    = shift;
     my $class   = shift;
@@ -127,16 +119,61 @@ around 'clear_value' => sub {
         ->clear_class_attribute_value( $self->name() );
 };
 
+override '_inline_instance_get' => sub {
+    my $self = shift;
+
+    return $self->associated_class()
+        ->inline_get_class_slot_value( $self->slots() );
+};
+
+
+override _inline_weaken_value => sub {
+    my $self = shift;
+    my ($instance, $value) = @_;
+    return unless $self->is_weak_ref;
+
+    my $mi = $self->associated_class->get_meta_instance;
+    return (
+        $self->associated_class->inline_weaken_class_slot_value( $self->slots(), $value ),
+            'if ref ' . $value . ';',
+    );
+};
+
+override '_inline_instance_set' => sub {
+    my $self  = shift;
+    shift;
+    my $value = shift;
+
+    my $meta = $self->associated_class();
+
+    my $code
+        = $meta->inline_set_class_slot_value( $self->slots(), $value ) . ";";
+
+    return $code;
+};
+
+override '_inline_instance_has' => sub {
+    my $self = shift;
+
+    return $self->associated_class()
+        ->inline_is_class_slot_initialized( $self->slots() );
+};
+
+override '_inline_clear_value' => sub {
+    my $self = shift;
+
+    return $self->associated_class()
+        ->inline_deinitialize_class_slot( $self->slots() );
+};
+
 1;
 
+# ABSTRACT: A trait for class attributes
+
 __END__
 
 =pod
 
-=head1 NAME
-
-MooseX::ClassAttribute::Trait::Attribute - A trait for class attributes
-
 =head1 DESCRIPTION
 
 This role modifies the behavior of class attributes in various
@@ -147,19 +184,8 @@ metaclasses, like C<MooseX::AttributeHelpers>.
 There are no new public methods implemented by this role. All it does
 is change the behavior of a number of existing methods.
 
-=head1 AUTHOR
-
-Dave Rolsky, C<< <autarch@urth.org> >>
-
 =head1 BUGS
 
 See L<MooseX::ClassAttribute> for details.
 
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2007-2010 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