NewDefaults.pm

filter: Statementstmt 95.2% 20 / 21 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 93.1% 27 / 29 CC 2 SCAR 3.1
CC
2
Cov
91%
default_for
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« NewDefaults/Magic.pm ↑ Summary
1 #
2 # This file is part of MooseX-NewDefaults
3 #
4 # This software is Copyright (c) 2011 by Chris Weyl.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package MooseX::NewDefaults;
11 {
12 6 $MooseX::NewDefaults::VERSION = '0.004';
13 }
14  
15 # ABSTRACT: Alter attribute defaults with less pain
16  
17 6 ▶use Moose 0.94 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 6 ▶use Moose::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 6 ▶use Moose::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 3 ▶sub default_for {
Subroutine default_for: called CC=2 SCAR=7.4
Pod documented
23 3 my ($meta, $attribute_name, $new_default) = (shift, shift, shift);
24  
25 # yes, Moose::Role will explode letting the caller know that roles don't
26 # currently support attribute extension... but that's M::R's problem, not
27 # ours :)
28  
29 3 ▶ my $sub
Branch: 1 branch
BranchTrueFalseTotal
$meta->isa('Moose::Meta::Role') ? : 0 3 3
30 = $meta->isa('Moose::Meta::Role')
31 ? \&Moose::Role::has
32 : \&Moose::has
33 ;
34  
35 # massage into what has() expects
36 3 @_ = ($meta, "+$attribute_name", default => $new_default);
37 3 goto \&$sub;
38 0 return;
39 }
40  
41 6 Moose::Exporter->setup_import_methods(with_meta => [ qw{ default_for } ]);
42  
43 6 !!42;
44  
45 __END__
« NewDefaults/Magic.pm ↑ Summary