InsideOut/Role/Meta/Instance.pm

filter: Statementstmt 76.1% 32 / 42 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 64.2% 9 / 14 Podpod 100% 7 / 7 totaltotal 76.1% 48 / 63 CC 1 SCAR 3.1
CC
1
Cov
76%
get_slot_value
2.0
deinitialize_slot
2.0
deinitialize_all_slots
2.0
CRAP 1.4
↑ Summary InsideOut.pm »
1 package MooseX::InsideOut::Role::Meta::Instance;
2 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 $MooseX::InsideOut::Role::Meta::Instance::VERSION = '0.106';
4 }
5  
6 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Hash::Util::FieldHash::Compat qw(fieldhash);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Scalar::Util qw(refaddr weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 fieldhash our %attr;
13  
14 2 ▶around create_instance => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
15 2 my $next = shift;
16 2 my $instance = shift->$next(@_);
17 2 $attr{refaddr $instance} = {};
18 2 return $instance;
19 2 };
20  
21 0 ▶sub get_slot_value {
Subroutine get_slot_value: not called CC=1 SCAR=6.9
Pod documented
22 0 my ($self, $instance, $slot_name) = @_;
23  
24 0 return $attr{refaddr $instance}->{$slot_name};
25 }
26  
27 2 ▶sub set_slot_value {
Subroutine set_slot_value: called CC=1 SCAR=0.0
Pod documented
28 2 my ($self, $instance, $slot_name, $value) = @_;
29  
30 2 return $attr{refaddr $instance}->{$slot_name} = $value;
31 }
32  
33 0 ▶sub deinitialize_slot {
Subroutine deinitialize_slot: not called CC=1 SCAR=6.9
Pod documented
34 0 my ($self, $instance, $slot_name) = @_;
35 0 return delete $attr{refaddr $instance}->{$slot_name};
36 }
37  
38 0 ▶sub deinitialize_all_slots {
Subroutine deinitialize_all_slots: not called CC=1 SCAR=6.9
Pod documented
39 0 my ($self, $instance) = @_;
40 0 $attr{refaddr $instance} = {};
41 }
42  
43 0 ▶sub is_slot_initialized {
Subroutine is_slot_initialized: not called CC=1 SCAR=6.9
Pod documented
44 0 my ($self, $instance, $slot_name) = @_;
45  
46 0 return exists $attr{refaddr $instance}->{$slot_name};
47 }
48  
49 0 ▶sub weaken_slot_value {
Subroutine weaken_slot_value: not called CC=1 SCAR=6.9
Pod documented
50 0 my ($self, $instance, $slot_name) = @_;
51 0 weaken $attr{refaddr $instance}->{$slot_name};
52 }
53  
54 2 ▶around inline_create_instance => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
55 2 my $next = shift;
56 2 my ($self, $class_variable) = @_;
57 2 my $code = $self->$next($class_variable);
58 2 $code = "do { my \$instance = ($code);";
59 2 $code .= sprintf(
60 '$%s::attr{Scalar::Util::refaddr($instance)} = {};',
61 __PACKAGE__,
62 );
63 2 $code .= '$instance }';
64 2 return $code;
65 2 };
66  
67 13 ▶sub inline_slot_access {
Subroutine inline_slot_access: called CC=1 SCAR=0.0
Pod documented
68 13 my ($self, $instance, $slot_name) = @_;
69 13 return sprintf '$%s::attr{Scalar::Util::refaddr(%s)}->{%s}',
70 __PACKAGE__, $instance, $slot_name;
71 }
72  
73 2 1;
74  
75  
76  
77 =pod
78  
79 =head1 NAME
80  
81 MooseX::InsideOut::Role::Meta::Instance
82  
83 =head1 VERSION
84  
85 version 0.106
86  
87 =head1 DESCRIPTION
88  
89 Meta-instance role implementing inside-out storage.
90  
91 =head1 METHODS
92  
93 =head2 create_instance
94  
95 =head2 get_slot_value
96  
97 =head2 set_slot_value
98  
99 =head2 deinitialize_slot
100  
101 =head2 deinitialize_all_slots
102  
103 =head2 is_slot_initialized
104  
105 =head2 weaken_slot_value
106  
107 =head2 inline_create_instance
108  
109 =head2 inline_slot_access
110  
111 See L<Class::MOP::Instance>.
112  
113 =head1 AUTHOR
114  
115 Hans Dieter Pearcey <hdp@cpan.org>
116  
117 =head1 COPYRIGHT AND LICENSE
118  
119 This software is copyright (c) 2011 by Hans Dieter Pearcey <hdp@cpan.org>.
120  
121 This is free software; you can redistribute it and/or modify it under
122 the same terms as the Perl 5 programming language system itself.
123  
124 =cut
125  
126  
127 __END__
↑ Summary InsideOut.pm »