Commit | Line | Data |
8ee73eeb |
1 | |
2 | package Moose::Meta::Method::Accessor; |
3 | |
4 | use strict; |
5 | use warnings; |
6 | |
55c361dc |
7 | use Try::Tiny; |
8 | |
bb8ef151 |
9 | our $VERSION = '1.9900'; |
e606ae5f |
10 | $VERSION = eval $VERSION; |
d44714be |
11 | our $AUTHORITY = 'cpan:STEVAN'; |
8ee73eeb |
12 | |
39b3bc94 |
13 | use base 'Moose::Meta::Method', |
d617b644 |
14 | 'Class::MOP::Method::Accessor'; |
15 | |
18748ad6 |
16 | sub _error_thrower { |
17 | my $self = shift; |
cc743de9 |
18 | return $self->associated_attribute |
19 | if ref($self) && defined($self->associated_attribute); |
20 | return $self->SUPER::_error_thrower; |
18748ad6 |
21 | } |
d617b644 |
22 | |
55c361dc |
23 | sub _compile_code { |
24 | my $self = shift; |
25 | my @args = @_; |
26 | try { |
27 | $self->SUPER::_compile_code(@args); |
28 | } |
29 | catch { |
30 | $self->throw_error( |
31 | 'Could not create writer for ' |
32 | . "'" . $self->associated_attribute->name . "' " |
33 | . 'because ' . $_, |
34 | error => $_, |
35 | ); |
36 | }; |
c9183ffc |
37 | } |
38 | |
f5f08b5f |
39 | sub _eval_environment { |
40 | my $self = shift; |
41 | |
42 | my $attr = $self->associated_attribute; |
43 | my $type_constraint_obj = $attr->type_constraint; |
44 | |
45 | return { |
46 | '$attr' => \$attr, |
47 | '$meta' => \$self, |
48 | '$type_constraint_obj' => \$type_constraint_obj, |
49 | '$type_constraint' => \( |
50 | $type_constraint_obj |
cc743de9 |
51 | ? $type_constraint_obj->_compiled_type_constraint |
52 | : undef |
f5f08b5f |
53 | ), |
54 | }; |
55 | } |
56 | |
f001c60f |
57 | sub _instance_is_inlinable { |
58 | my $self = shift; |
59 | return $self->associated_attribute->associated_class->instance_metaclass->is_inlinable; |
60 | } |
61 | |
62 | sub _generate_reader_method { |
63 | my $self = shift; |
64 | $self->_instance_is_inlinable ? $self->_generate_reader_method_inline(@_) |
65 | : $self->SUPER::_generate_reader_method(@_); |
66 | } |
67 | |
68 | sub _generate_writer_method { |
69 | my $self = shift; |
70 | $self->_instance_is_inlinable ? $self->_generate_writer_method_inline(@_) |
71 | : $self->SUPER::_generate_writer_method(@_); |
72 | } |
73 | |
74 | sub _generate_accessor_method { |
75 | my $self = shift; |
76 | $self->_instance_is_inlinable ? $self->_generate_accessor_method_inline(@_) |
77 | : $self->SUPER::_generate_accessor_method(@_); |
78 | } |
79 | |
80 | sub _generate_predicate_method { |
81 | my $self = shift; |
82 | $self->_instance_is_inlinable ? $self->_generate_predicate_method_inline(@_) |
83 | : $self->SUPER::_generate_predicate_method(@_); |
84 | } |
85 | |
86 | sub _generate_clearer_method { |
87 | my $self = shift; |
88 | $self->_instance_is_inlinable ? $self->_generate_clearer_method_inline(@_) |
89 | : $self->SUPER::_generate_clearer_method(@_); |
90 | } |
8ecb1fa0 |
91 | |
6e50f7e9 |
92 | sub _writer_value_needs_copy { |
93 | shift->associated_attribute->_writer_value_needs_copy(@_); |
94 | } |
c350159f |
95 | |
1e2c801e |
96 | sub _inline_tc_code { |
6e50f7e9 |
97 | shift->associated_attribute->_inline_tc_code(@_); |
1e2c801e |
98 | } |
99 | |
d617b644 |
100 | sub _inline_check_constraint { |
6e50f7e9 |
101 | shift->associated_attribute->_inline_check_constraint(@_); |
d617b644 |
102 | } |
103 | |
104 | sub _inline_check_lazy { |
6e50f7e9 |
105 | shift->associated_attribute->_inline_check_lazy(@_); |
9df136d0 |
106 | } |
d617b644 |
107 | |
1e2c801e |
108 | sub _inline_store_value { |
6e50f7e9 |
109 | shift->associated_attribute->_inline_instance_set(@_) . ';'; |
d617b644 |
110 | } |
111 | |
3dda07f5 |
112 | sub _inline_get_old_value_for_trigger { |
6e50f7e9 |
113 | shift->associated_attribute->_inline_get_old_value_for_trigger(@_); |
3dda07f5 |
114 | } |
115 | |
d617b644 |
116 | sub _inline_trigger { |
6e50f7e9 |
117 | shift->associated_attribute->_inline_trigger(@_); |
d617b644 |
118 | } |
119 | |
1e2c801e |
120 | sub _get_value { |
6e50f7e9 |
121 | shift->associated_attribute->_inline_instance_get(@_); |
d617b644 |
122 | } |
123 | |
1e2c801e |
124 | sub _has_value { |
6e50f7e9 |
125 | shift->associated_attribute->_inline_instance_has(@_); |
d617b644 |
126 | } |
8ee73eeb |
127 | |
128 | 1; |
129 | |
130 | __END__ |
131 | |
132 | =pod |
133 | |
39b3bc94 |
134 | =head1 NAME |
135 | |
ecb59493 |
136 | Moose::Meta::Method::Accessor - A Moose Method metaclass for accessors |
39b3bc94 |
137 | |
138 | =head1 DESCRIPTION |
139 | |
ba4dfb8e |
140 | This class is a subclass of L<Class::MOP::Method::Accessor> that |
73f769fc |
141 | provides additional Moose-specific functionality, all of which is |
142 | private. |
ecb59493 |
143 | |
73f769fc |
144 | To understand this class, you should read the the |
ba4dfb8e |
145 | L<Class::MOP::Method::Accessor> documentation. |
39b3bc94 |
146 | |
147 | =head1 BUGS |
148 | |
d4048ef3 |
149 | See L<Moose/BUGS> for details on reporting bugs. |
39b3bc94 |
150 | |
151 | =head1 AUTHOR |
152 | |
153 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
154 | |
155 | Yuval Kogman E<lt>nothingmuch@woobling.comE<gt> |
156 | |
157 | =head1 COPYRIGHT AND LICENSE |
158 | |
7e0492d3 |
159 | Copyright 2006-2010 by Infinity Interactive, Inc. |
39b3bc94 |
160 | |
161 | L<http://www.iinteractive.com> |
162 | |
163 | This library is free software; you can redistribute it and/or modify |
164 | it under the same terms as Perl itself. |
165 | |
51308c23 |
166 | =cut |