AttributeShortcuts/Trait/Attribute/HasAnonBuilder.pm

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 22 / 22 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
_mxas_builder_name
1.0
CRAP 1.0
« AttributeShortcuts/Trait/Role/Attribute.pm ↑ Summary AttributeShortcuts/Trait/Method/Builder.pm »
1 #
2 # This file is part of MooseX-AttributeShortcuts
3 #
4 # This software is Copyright (c) 2017, 2015, 2014, 2013, 2012, 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::AttributeShortcuts::Trait::Attribute::HasAnonBuilder;
11 32 our $AUTHORITY = 'cpan:RSRCHBOY';
12 32 $MooseX::AttributeShortcuts::Trait::Attribute::HasAnonBuilder::VERSION = '0.037';
13 # ABSTRACT: Attributes, etc, common to both the role-attribute and attribute traits
14  
15 32 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 32 ▶use namespace::autoclean 0.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 32 has anon_builder => (
19 reader => 'anon_builder',
20 writer => '_set_anon_builder',
21 isa => 'CodeRef',
22 predicate => 'has_anon_builder',
23 # init_arg => '_anon_builder',
24 );
25  
26 32 has anon_builder_installed => (
27 traits => ['Bool'],
28 is => 'ro',
29 default => 0,
30 handles => {
31 _set_anon_builder_installed => 'set',
32 },
33 );
34  
35 # FIXME Something Odd keeps this from succeeding as we'd like.
36 #requires 'canonical_builder_prefix';
37  
38 24 ▶sub _mxas_builder_name {
Subroutine _mxas_builder_name: called CC=1 SCAR=0.0
39 24 my ($class, $name) = @_;
40  
41 24 return $class->canonical_builder_prefix . $name;
42 }
43  
44 # this is identical between role and class attributes
45  
46 9 ▶sub _builder_method_meta {
Subroutine _builder_method_meta: called CC=1 SCAR=0.0
47 9 my ($self, $thing) = @_;
48  
49 9 my $dc = { %{$self->definition_context} };
50  
51 $dc->{description}
52 9 = 'builder ' . $thing->name . '::' . $self->builder
53 . ' of attribute ' . $self->name
54 ;
55  
56 9 return $self->builder_method_metaclass->wrap($self->anon_builder =>
57 associated_attribute => $self,
58 associated_metaclass => $thing,
59 name => $self->builder,
60 package_name => $thing->name,
61 definition_context => $dc,
62 );
63 }
64  
65  
66 32 !!42;
67  
68 __END__
« AttributeShortcuts/Trait/Role/Attribute.pm ↑ Summary AttributeShortcuts/Trait/Method/Builder.pm »