File Coverage

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