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