Commit | Line | Data |
0f24a39d |
1 | package MooseX::ClassAttribute::Meta::Method::Accessor; |
2 | |
3 | use warnings; |
4 | use strict; |
5 | |
6 | our $VERSION = '0.01'; |
7 | our $AUTHORITY = 'cpan:DROLSKY'; |
8 | |
9 | use Moose; |
10 | |
11 | extends 'Moose::Meta::Method::Accessor'; |
12 | |
13 | |
14 | sub _inline_store { |
15 | my $self = shift; |
16 | my $instance = shift; |
17 | my $value = shift; |
18 | |
19 | my $attr = $self->associated_attribute(); |
20 | |
21 | my $mi = $attr->associated_class()->get_meta_instance(); |
22 | my $slot_name = $attr->slots(); |
23 | |
24 | my $package_var = sprintf q{$%s::__ClassAttribute{'%s'}}, $attr->associated_class()->name(), $slot_name; |
25 | |
26 | my $code = "$package_var = $value;"; |
27 | $code .= "Scalar::Util::weaken $package_var;" |
28 | if $attr->is_weak_ref(); |
29 | |
30 | return $code; |
31 | } |
32 | |
33 | sub _inline_get { |
34 | my $self = shift; |
35 | my $instance = shift; |
36 | |
37 | my $attr = $self->associated_attribute(); |
38 | |
39 | my $mi = $attr->associated_class()->get_meta_instance(); |
40 | my $slot_name = $attr->slots(); |
41 | |
42 | return sprintf q{$%s::__ClassAttribute{'%s'}}, $attr->associated_class()->name(), $slot_name; |
43 | } |
44 | |
0f24a39d |
45 | |
46 | 1; |