Data-Object-Attributes
view release on metacpan or search on metacpan
the Moo documentation for more details.
has-use
package Example::HasUse;
use Moo;
use routines;
use Data::Object::Attributes;
has data => (
is => 'ro',
use => ['service', 'time']
);
method service($type, @args) {
$self->{serviced} = 1;
return time if $type eq 'time';
}
package main;
my $example = Example::HasUse->new;
This package supports the use directive denotes that the attribute will
be constructed on-demand, i.e. is lazy, using a custom builder meant to
perform service construction. This directive exists to provide a simple
dependency injection mechanism for class attributes. This ability is
not supported by the Moo object superclass.
has-wkr
package Example::HasWkr;
use Moo;
use Data::Object::Attributes;
has data => (
is => 'ro',
wkr => 1
);
package main;
my $data = do {
my ($a, $b);
$a = { time => time };
$b = { time => $a };
$a->{time} = $b;
$a
};
my $example = Example::HasWkr->new(data => $data);
This package supports the wkr and weak_ref directives is used to denote
if the attribute's value should be weakened. See the Moo documentation
for more details.
has-wrt
package Example::HasWrt;
use Moo;
use Data::Object::Attributes;
has data => (
is => 'ro',
wrt => 'set_data'
);
package main;
my $example = Example::HasWrt->new;
This package supports the wrt and writer directives denotes the name of
the method to be used to "write" and return the attribute's value. See
the Moo documentation for more details.
AUTHOR
Al Newkirk, awncorp@cpan.org
LICENSE
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under
the terms of the The Apache License, Version 2.0, as elucidated in the
"license file"
<https://github.com/iamalnewkirk/data-object-attributes/blob/master/LICENSE>.
PROJECT
Wiki <https://github.com/iamalnewkirk/data-object-attributes/wiki>
Project <https://github.com/iamalnewkirk/data-object-attributes>
Initiatives
<https://github.com/iamalnewkirk/data-object-attributes/projects>
Milestones
<https://github.com/iamalnewkirk/data-object-attributes/milestones>
Contributing
<https://github.com/iamalnewkirk/data-object-attributes/blob/master/CONTRIBUTE.md>
Issues <https://github.com/iamalnewkirk/data-object-attributes/issues>
( run in 1.090 second using v1.01-cache-2.11-cpan-39bf76dae61 )