lib/MooseX/FormFuChainedAccessors.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 43 SCAR 6.9
CC
1
Cov
0%
_generate_accessor_method_inline
2.0
_generate_writer_method_inline
2.0
BEGIN
2.0
CRAP 2.0
1 # This file is a modified copy of MooseX/ChainedAccessors.pm
2 # Carl Franks 2014
3  
4 #
5 # This file is part of MooseX-Attribute-Chained
6 #
7 # This software is copyright (c) 2012 by Moritz Onken.
8 #
9 # This is free software; you can redistribute it and/or modify it under
10 # the same terms as the Perl 5 programming language system itself.
11 #
12 package MooseX::FormFuChainedAccessors;
13  
14 use strict;
15 our $VERSION = '2.05'; # VERSION
16  
17 # ABSTRACT: DEPRECATED
18 use strict;
19 use warnings;
20 use Carp qw(confess);
21 use Try::Tiny;
22 use base 'Moose::Meta::Method::Accessor';
23  
24 sub _generate_accessor_method_inline {
25 my $self = shift;
26 my $attr = $self->associated_attribute;
27  
28 return try {
29 $self->_compile_code([
30 'sub {',
31 'if (@_ > 1) {',
32 $attr->_inline_set_value('$_[0]', '$_[1]'),
33 'return $_[0];',
34 '}',
35 $attr->_inline_get_value('$_[0]'),
36 '}',
37 ]);
38 }
39 catch {
40 confess "Could not generate inline accessor because : $_";
41 };
42 }
43  
44 sub _generate_writer_method_inline {
45 my $self = shift;
46 my $attr = $self->associated_attribute;
47  
48 return try {
49 $self->_compile_code([
50 'sub {',
51 $attr->_inline_set_value('$_[0]', '$_[1]'),
52 '$_[0]',
53 '}',
54 ]);
55 }
56 catch {
57 confess "Could not generate inline writer because : $_";
58 };
59 }
60  
61 1;