File Coverage

blib/lib/MooseX/AttributeShortcuts/Trait/Attribute/HasAnonBuilder.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 17 17 100.0


line stmt bran cond sub pod time code
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             our $AUTHORITY = 'cpan:RSRCHBOY';
12             $MooseX::AttributeShortcuts::Trait::Attribute::HasAnonBuilder::VERSION = '0.037';
13             # ABSTRACT: Attributes, etc, common to both the role-attribute and attribute traits
14              
15 28     28   15443 use Moose::Role;
  28         73  
  28         226  
16 28     28   138560 use namespace::autoclean 0.24;
  28         731  
  28         212  
17              
18             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             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             sub _mxas_builder_name {
39 24     24   83 my ($class, $name) = @_;
40              
41 24         116 return $class->canonical_builder_prefix . $name;
42             }
43              
44             # this is identical between role and class attributes
45              
46             sub _builder_method_meta {
47 9     9   29 my ($self, $thing) = @_;
48              
49 9         20 my $dc = { %{$self->definition_context} };
  9         85  
50              
51             $dc->{description}
52 9         99 = 'builder ' . $thing->name . '::' . $self->builder
53             . ' of attribute ' . $self->name
54             ;
55              
56 9         39 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             !!42;
67              
68             __END__
69              
70             =pod
71              
72             =encoding UTF-8
73              
74             =for :stopwords Chris Weyl Alders David Etheridge Graham Karen Knop Olaf Steinbrunner
75              
76             =head1 NAME
77              
78             MooseX::AttributeShortcuts::Trait::Attribute::HasAnonBuilder - Attributes, etc, common to both the role-attribute and attribute traits
79              
80             =head1 VERSION
81              
82             This document describes version 0.037 of MooseX::AttributeShortcuts::Trait::Attribute::HasAnonBuilder - released November 20, 2017 as part of MooseX-AttributeShortcuts.
83              
84             =head1 DESCRIPTION
85              
86             This is a role containing the elements common to both the
87             L<role attribute trait|MooseX::AttributeShortcuts::Trait::Role::Attribute>
88             and L<attribute trait|MooseX::AttributeShortcuts::Trait::Attribute>
89             of L<MooseX::AttributeShortcuts>.
90              
91             =head1 ATTRIBUTES
92              
93             =head2 anon_builder
94              
95             CodeRef, read-only. Stores the code reference that will become the
96             attribute's builder. This code reference will be installed in the role or
97             class as a method, as appropriate.
98              
99             =head2 anon_builder_installed
100              
101             Boolean, read-only. If true, the code reference in L</anon_builder> has been
102             installed as a method.
103              
104             =head1 METHODS
105              
106             =head2 has_anon_builder
107              
108             Predicate for L</anon_builder>.
109              
110             =head1 SEE ALSO
111              
112             Please see those modules/websites for more information related to this module.
113              
114             =over 4
115              
116             =item *
117              
118             L<MooseX::AttributeShortcuts|MooseX::AttributeShortcuts>
119              
120             =back
121              
122             =head1 BUGS
123              
124             Please report any bugs or feature requests on the bugtracker website
125             L<https://github.com/RsrchBoy/moosex-attributeshortcuts/issues>
126              
127             When submitting a bug or request, please include a test-file or a
128             patch to an existing test-file that illustrates the bug or desired
129             feature.
130              
131             =head1 AUTHOR
132              
133             Chris Weyl <cweyl@alumni.drew.edu>
134              
135             =head1 COPYRIGHT AND LICENSE
136              
137             This software is Copyright (c) 2017, 2015, 2014, 2013, 2012, 2011 by Chris Weyl.
138              
139             This is free software, licensed under:
140              
141             The GNU Lesser General Public License, Version 2.1, February 1999
142              
143             =cut