1Mo::builder(3)        User Contributed Perl Documentation       Mo::builder(3)
2
3
4

Name

6       Mo::builder - Adds the builder feature to Mo's has
7

Synopsis

9           use Mo qw'builder';
10           has name => ( builder => 'name_lookup' );
11
12           sub name_lookup {
13               my ($self) = @_;
14               ...
15           }
16

Description

18       Adds the "builder" parameter to has, which expects a method name, which
19       is executed on $self to set the attribute if it hasn't been set yet.
20

Laziness

22       Builders in Mo are lazy by default.  This can be changed by explicitly
23       setting the "lazy" argument to false, in order to cause it to be
24       initialized during instantiation.
25
26           use Mo qw'builder';
27           has status => ( builder => '_build_status' );             # lazy
28           has source => ( builder => '_build_source', lazy => 1);   # lazy
29           has target => ( builder => '_build_target', lazy => 0);   # eager
30
31       To change the default behavior and make builders to be initialized
32       eagerly by default, import "nonlazy".
33
34           use Mo qw'builder nonlazy';
35           has status => ( builder => '_build_status' );             # eager
36           has source => ( builder => '_build_source', lazy => 1);   # lazy
37           has target => ( builder => '_build_target', lazy => 0);   # eager
38
39
40
41perl v5.32.0                      2020-07-28                    Mo::builder(3)
Impressum