1MooseX::Role::TraitConsUtsreurctCoorn(t3r)ibuted Perl DoMcouomseenXt:a:tRioolne::TraitConstructor(3)
2
3
4

NAME

6       MooseX::Role::TraitConstructor - A wrapper for "new" that can accept a
7       "traits" parameter.
8

SYNOPSIS

10           package Foo;
11           use Moose;
12
13               with qw(MooseX::Role::TraitConstructor);
14
15
16           package Foo::Bah;
17
18           sub bah_method { ... }
19
20
21
22           my $foo = Foo->new( traits => [qw( Bah )] );
23
24           $foo->bah_method;
25

DESCRIPTION

27       This role allows you to easily accept a "traits" argument (or another
28       name) into your constructor, which will easily mix roles into an
29       anonymous class before construction, much like Moose::Meta::Attribute
30       does.
31

METHODS

33       constructor_trait_param
34           Returns the string "traits".
35
36           Override to rename the parameter.
37
38       new_with_traits %params
39       new_with_traits $params
40           A "new" in Moose::Object like parameter processor which will call
41           "new" on the return value of "interpolate_class_from_params".
42
43       interpolate_class_from_params $params
44           This method will automatically create an anonymous class with the
45           roles from the "traits" param mixed into it if one exists.
46
47           If not the normal class name will be returned.
48
49           Will remove the "traits" parameter from $params.
50
51           Also works as an instance method, but always returns a class name.
52
53           In list context also returns the actual list of roles mixed into
54           the class.
55
56       process_constructor_traits $params, @traits
57           Calls "filter_constructor_traits" on the result of
58           "resolve_constructor_traits".
59
60       resolve_constructor_traits $params, @traits
61           Attempt to load the traits specified in @traits usinc
62           "resolve_constructor_trait"
63
64       guess_original_class_name $params
65       resolve_constructor_trait $params, $possible_root, $trait
66           Attempts to get a processed name from "process_trait_name", and
67           then tries to load that.
68
69           If "process_trait_name" didn't return a true value or its return
70           value could not be loaded then $trait will be tried.
71
72           If nothing could be loaded an error is thrown.
73
74           $possible_root is the name of the first non anonymous class in the
75           "linearized_isa", usually $class, but will DWIM in case $class has
76           already been interpolated with traits from a named class.
77
78       process_trait_name $trait, $params, $possible_root
79           Returns "join "::", $possible_root, $trait".
80
81           You probably want to override this method.
82
83       filter_constructor_traits $params, $traits,
84           Returns all the the roles that the invocant class doesn't already
85           do (uses "does").
86

VERSION CONTROL

88       <http://code2.0beta.co.uk/moose/svn/>. Ask on #moose for commit bits.
89

AUTHOR

91       Yuval Kogman <nothingmuch@woobling.org>
92
94               Copyright (c) 2008 Yuval Kogman. All rights reserved
95               This program is free software; you can redistribute
96               it and/or modify it under the same terms as Perl itself.
97
98
99
100perl v5.34.0                      2021-07-22 MooseX::Role::TraitConstructor(3)
Impressum