privatize apply_class_attributes and update pod coverage exclusions
[gitmo/MooseX-ClassAttribute.git] / lib / MooseX / ClassAttribute / Meta / Method / Accessor.pm
CommitLineData
bb70fe3a 1package MooseX::ClassAttribute::Meta::Method::Accessor;
2
3use strict;
4use warnings;
5
67e6eaa5 6use namespace::autoclean;
bb70fe3a 7use Moose;
8
9extends 'Moose::Meta::Method::Accessor';
10
67e6eaa5 11sub _generate_predicate_method_inline {
12 my $attr = (shift)->associated_attribute;
bb70fe3a 13
67e6eaa5 14 my $code
15 = eval 'sub {'
16 . $attr->associated_class()
17 ->inline_is_class_slot_initialized( $attr->name() ) . '}';
bb70fe3a 18
19 confess "Could not generate inline predicate because : $@" if $@;
20
21 return $code;
22}
23
67e6eaa5 24sub _generate_clearer_method_inline {
bb70fe3a 25 my $attr = (shift)->associated_attribute;
bb70fe3a 26 my $meta_instance = $attr->associated_class->instance_metaclass;
27
67e6eaa5 28 my $code
29 = eval 'sub {'
30 . $attr->associated_class()
31 ->inline_deinitialize_class_slot( $attr->name() ) . '}';
bb70fe3a 32
33 confess "Could not generate inline clearer because : $@" if $@;
34
35 return $code;
36}
37
67e6eaa5 38sub _inline_store {
39 my $self = shift;
bb70fe3a 40 shift;
41 my $value = shift;
42
43 my $attr = $self->associated_attribute();
44
bb70fe3a 45 my $meta = $attr->associated_class();
46
67e6eaa5 47 my $code
48 = $meta->inline_set_class_slot_value( $attr->slots(), $value ) . ";";
49 $code
50 .= $meta->inline_weaken_class_slot_value( $attr->slots(), $value )
51 . ";"
bb70fe3a 52 if $attr->is_weak_ref();
53
54 return $code;
55}
56
67e6eaa5 57sub _inline_get {
58 my $self = shift;
bb70fe3a 59
60 my $attr = $self->associated_attribute;
61 my $meta = $attr->associated_class();
62
7aab7f6c 63 return $meta->inline_get_class_slot_value( $attr->slots() );
bb70fe3a 64}
65
67e6eaa5 66sub _inline_access {
67 my $self = shift;
bb70fe3a 68
69 my $attr = $self->associated_attribute;
70 my $meta = $attr->associated_class();
71
7aab7f6c 72 return $meta->inline_class_slot_access( $attr->slots() );
bb70fe3a 73}
74
67e6eaa5 75sub _inline_has {
bb70fe3a 76 my $self = shift;
77
78 my $attr = $self->associated_attribute;
79 my $meta = $attr->associated_class();
80
7aab7f6c 81 return $meta->inline_is_class_slot_initialized( $attr->slots() );
bb70fe3a 82}
83
67e6eaa5 84sub _inline_init_slot {
bb70fe3a 85 my $self = shift;
86
87 return $self->_inline_store( undef, $_[-1] );
88}
89
67e6eaa5 90sub _inline_check_lazy {
bb70fe3a 91 my $self = shift;
92
67e6eaa5 93 return $self->SUPER::_inline_check_lazy( q{'}
94 . $self->associated_attribute()->associated_class()->name()
95 . q{'} );
bb70fe3a 96}
97
67e6eaa5 98sub _inline_get_old_value_for_trigger {
8207dfe7 99 my $self = shift;
100
101 my $attr = $self->associated_attribute();
102 return '' unless $attr->has_trigger();
103
67e6eaa5 104 my $pred = $attr->associated_class()
105 ->inline_is_class_slot_initialized( $attr->name() );
8207dfe7 106
107 return
67e6eaa5 108 'my @old = '
8207dfe7 109 . $pred . q{ ? }
67e6eaa5 110 . $self->_inline_get()
111 . q{ : ()} . ";\n";
8207dfe7 112
113}
114
bb70fe3a 1151;
116
a1c01f67 117__END__
118
7a4a3b1e 119=pod
120
121=head1 NAME
122
123MooseX::ClassAttribute::Meta::Method::Accessor - Accessor method generation for class attributes
124
125=head1 DESCRIPTION
126
127This class overrides L<Moose::Meta::Method::Accessor> to do code
128generation properly for class attributes.
129
130=head1 AUTHOR
131
132Dave Rolsky, C<< <autarch@urth.org> >>
133
134=head1 BUGS
135
136See L<MooseX::ClassAttribute> for details.
137
138=head1 COPYRIGHT & LICENSE
139
140Copyright 2007-2008 Dave Rolsky, All Rights Reserved.
141
142This program is free software; you can redistribute it and/or modify
143it under the same terms as Perl itself.
144
145=cut