1 package MooseX::ClassAttribute::Meta::Method::Accessor;
8 use namespace::autoclean;
11 extends 'Moose::Meta::Method::Accessor';
13 sub _generate_predicate_method_inline {
14 my $attr = (shift)->associated_attribute;
18 . $attr->associated_class()
19 ->inline_is_class_slot_initialized( $attr->name() ) . '}';
21 confess "Could not generate inline predicate because : $@" if $@;
26 sub _generate_clearer_method_inline {
27 my $attr = (shift)->associated_attribute;
28 my $meta_instance = $attr->associated_class->instance_metaclass;
32 . $attr->associated_class()
33 ->inline_deinitialize_class_slot( $attr->name() ) . '}';
35 confess "Could not generate inline clearer because : $@" if $@;
45 my $attr = $self->associated_attribute();
47 my $meta = $attr->associated_class();
50 = $meta->inline_set_class_slot_value( $attr->slots(), $value ) . ";";
52 .= $meta->inline_weaken_class_slot_value( $attr->slots(), $value )
54 if $attr->is_weak_ref();
62 my $attr = $self->associated_attribute;
63 my $meta = $attr->associated_class();
65 return $meta->inline_get_class_slot_value( $attr->slots() );
71 my $attr = $self->associated_attribute;
72 my $meta = $attr->associated_class();
74 return $meta->inline_class_slot_access( $attr->slots() );
80 my $attr = $self->associated_attribute;
81 my $meta = $attr->associated_class();
83 return $meta->inline_is_class_slot_initialized( $attr->slots() );
86 sub _inline_init_slot {
89 return $self->_inline_store( undef, $_[-1] );
92 sub _inline_check_lazy {
95 return $self->SUPER::_inline_check_lazy( q{'}
96 . $self->associated_attribute()->associated_class()->name()
100 sub _inline_get_old_value_for_trigger {
103 my $attr = $self->associated_attribute();
104 return '' unless $attr->has_trigger();
106 my $pred = $attr->associated_class()
107 ->inline_is_class_slot_initialized( $attr->name() );
112 . $self->_inline_get()
125 MooseX::ClassAttribute::Meta::Method::Accessor - Accessor method generation for class attributes
129 This class overrides L<Moose::Meta::Method::Accessor> to do code
130 generation properly for class attributes.
134 Dave Rolsky, C<< <autarch@urth.org> >>
138 See L<MooseX::ClassAttribute> for details.
140 =head1 COPYRIGHT & LICENSE
142 Copyright 2007-2010 Dave Rolsky, All Rights Reserved.
144 This program is free software; you can redistribute it and/or modify
145 it under the same terms as Perl itself.